What is weekday() method in python?



The weekday() method is used to returns the particular day of the week.

Example

import datetime
import calendar
#defining function named called findweekDay
def findWeekDay(date):
i = datetime.datetime.strptime(date, '%d %m %Y').weekday()
return (calendar.day_name[i])

date = '24 05 2019'
print(findWeekDay(date))

Output

friday
raja
Sri
Published on 24-May-2019 15:38:52
Advertisements