我有一个工作日整数(0,1,2...) ,我需要得到日名(‘ Monday’,‘ Monday’,...)。
是否有内置的 Python 函数或实现方法?
下面是我编写的函数,它可以工作,但是我想从内置的 datetime lib 中获得一些东西。
def dayNameFromWeekday(weekday):
if weekday == 0:
return "Monday"
if weekday == 1:
return "Tuesday"
if weekday == 2:
return "Wednesday"
if weekday == 3:
return "Thursday"
if weekday == 4:
return "Friday"
if weekday == 5:
return "Saturday"
if weekday == 6:
return "Sunday"