Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python year from date

import datetime
date = '2021-05-21 11:22:03'
datem = datetime.datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
print(datem.day)        # 25
print(datem.month)      # 5
print(datem.year)       # 2021
print(datem.hour)       # 11
print(datem.minute)     # 22
print(datem.second)     # 3
Comment

how to get the year and month in python

import calander
ear = int(input("Input the year:- "))
Month = int(input("Input the month:- "))
print(calendar.month(y, m))
Comment

PREVIOUS NEXT
Code Example
Python :: python get minute from datetime 
Python :: python datetime strptime hour minute second 
Python :: dataframe deep copy 
Python :: python generate secret key 
Python :: text to ascii art python 
Python :: python turtle sierpinski triangle 
Python :: csrf token exempt django 
Python :: check key pressed pygame 
Python :: get video length python 
Python :: _csv.Error: field larger than field limit (131072) 
Python :: brownie get active network 
Python :: last element in dictionary python 
Python :: python condition if dataype 
Python :: pygame keyboard input 
Python :: python roll dice 100 times 
Python :: json not readable python 
Python :: turn off pycache python 
Python :: pandas to csv encoding 
Python :: python read dictionary from file 
Python :: filter dataframe by index 
Python :: Sin , Cos Graph using python turtle. 
Python :: How to subtract a day from a date? 
Python :: no module named pyplot 
Python :: the day before today python datetime 
Python :: getpass 
Python :: how to set google chrome as default browser when coding with python using webbroiwser module 
Python :: difference between two dates in days python 
Python :: what is ycor in python turle 
Python :: if(guess_password == list(password): 
Python :: is prime python 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =