from datetime import datetime b='2021-04-26 11:23:56' c = datetime.strptime(b, "%Y-%m-%d %H:%M:%S") print(c) # datetime.datetime(2021, 4, 26, 11, 23, 56)
from datetime import datetime a = datetime.now() c = datetime.datetime(2021, 4, 26, 11, 23, 56) d = (a-c).seconds print(d) # 2401 (秒)