pyqt-todolist/test/TimeTest.py

14 lines
566 B
Python
Raw Normal View History

2022-04-07 21:11:37 +08:00
import datetime
import time
weekday = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
weekday_index = datetime.datetime.now().weekday()
month = datetime.datetime.now().month
day = datetime.datetime.now().day
2022-04-17 22:36:19 +08:00
print(datetime.datetime.now())
2022-04-07 21:11:37 +08:00
print(str(month) + '' + str(day) + '日,' + weekday[weekday_index])
2022-04-17 22:36:19 +08:00
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'))