代码:
#!/usr/bin/python # -*- coding: UTF-8 -*- import datetime dd = raw_input("输入日期:") dd = datetime.datetime.strptime(dd, "%Y%m%d") print dd.timetuple().tm_yday
输出:
输入日期:20200608 160