Python中 获取到今天为止这个周过了几天
import datetime
def get_week():
# 获取今天日期
today = datetime.date.today()
# 这周一的日期
monday = datetime.date.today()
one_day = datetime.timedelta(days=1)
while monday.weekday() != 0:
monday -= one_day
return (today-week).days+1
if __name__ == '__main__':
print('这周第: ', get_week(), '天')