4 odpowiedzi
+ 6
import calendar
yy = 2020
mm = 1
print(calendar.month(yy, mm))
Yes you can see this .
Or try my code
https://code.sololearn.com/cU9R4hgRAqZy/?ref=app
+ 4
Handling of date and / or time information should be done with a datetime object. This object not only holds the values like day, month, year or hour, minute and so on, it also has a number of methods() and a great way to format the output of these data.
If i have a date as such an object, weekday or what ever you need can be accessed. You can also calculate with date and time by adding or subtracting or calculating a difference between 2 dates can be obtained.
Here are some basic tasks with datetime objects:
import datetime as dt
from datetime import datetime as dtdt
sDate = '21,12,2019'
dtDate = dtdt.strptime(sDate, "%d,%m,%Y")
print(f"Day/Month/Year {dtdt.strftime(dtDate, '%d/%m/%Y')}")
print(f"Year/Month/Day {dtdt.strftime(dtDate, '%Y/%m/%d')}")
print(f"Day, Month, Day: {dtdt.strftime(dtDate, '%A, %d. %B %Y')}")
print(dtDate.day)
print()
# alternative input of date time values
dobj = dt.date(2019,12,21)
print(f"Day, Month, Day: {dtdt.strftime(dobj, '%A, %d. %B %Y')}")
+ 2
Calendar module
,Works here ,for more info
https://stackoverflow.com/questions/36341484/get-day-name-from-weekday-int
+ 2
https://stackoverflow.com/questions/9847213/how-do-i-get-the-day-of-week-given-a-date