import datetime import time weekday = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"] weekday_index = datetime.datetime.now().weekday() month = datetime.datetime.now().month day = datetime.datetime.now().day print(datetime.datetime.now()) print(str(month) + '月' + str(day) + '日,' + weekday[weekday_index]) time1 = '2022-04-17 20:39:10.242742' time2 = datetime.datetime.now().strptime('2022-04-17 20:39:10', '%Y-%m-%d %H:%M:%S') print(time2, type(time2)) print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))