如何分别获取当前日期的年月日以及在一年中的第几天
import time
localtime = time.localtime(time.time())
print(localtime)
print(type(localtime))
time.struct_time(tm_year=2020, tm_mon=3, tm_mday=10, tm_hour=20, tm_min=42, tm_sec=21, tm_wday=1, tm_yday=70, tm_isdst=0)
<class 'time.struct_time'>
print(localtime.tm_year)
print(loclatime.tm_mon)
print(localtime.tm_mday)
print(localtime.tm_hour)
print(localtime.tm_yday)
print(localtime[7])
2020
3
10
20
70
70
正文完