How to display the day of the week in python and the day of the week in python
This example describes how to display the day of the week in python. Share it with you for your reference. The specific implementation method is as follows:
# Find the day of the week of a given date # Python will traps impossible dates like (1900, 2, 29) # tested with Python24 vegaseat 01aug2005from datetime import date # a typical birthday year, month, day # or change it to your own birthday... birthday = date (1983, 12, 25) dayList = ['monday', 'tuesday', 'wednesday', 'thursday', 'Friday', 'saturday ', 'sunday'] # date. weekday () returns 0 for Monday and so on, so pick the day string from the dayListprint "The day of the week on % s was a % s" % (birthday. strftime ("% d % B % Y"), dayList [date. weekday (birthday)])
I hope this article will help you with Python programming.