a = datetime.datetime.now().year
b = datetime.datetime.now().month
c = datetime.datetime.now().day
print(a)
print(b)
print(c)
2020
7
21
dayOfWeek = datetime.datetime.now().weekday()
print(dayOfWeek)
dayOfWeek = datetime.datetime.today().weekday()
print(dayOfWeek)
注意:datetime类的weekday()方法可以获得datetime是星期几,注意weekday()返回的是0~6,是星期一到星期日,返回的int类型。