import datetime
import calendar

#获取当天日期值
currentdate = datetime.date.today()
print(currentdate)

year= currentdate.year
month = currentdate.month
day = currentdate.day

print(year,month,day)

print(calendar.weekday(year,month,day))
currentday =calendar.weekday(year,month,day)
# 系统默认:星期一作为一周的第一天(即:0),星期日作为一周的最后一天(即:6)

print(currentday)


#判断当天是周几?
if currentday == 0:
    print("当天为周一")
elif currentday ==1:
    print("当天为周二")
elif currentday ==2:
    print("当天为周三")
elif currentday ==3:
    print("当天为周四")
elif currentday == 4:
    print("当天为周五")
elif currentday == 5:
    print("当天为周六")
else:
    print("当天为周七")

#判断当天是否为周末
if currentday > 5:
    print("当天为周末")
else:
    print("工作日")


import time

print(time.localtime())
#  打印当前时间是本年的第几周
print(time.strftime("%W"))

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2021-12-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案