1、日期格式–> 字符串(datetime.datetime) import datetime as dt date1 = dt.datetime.today() # datetime.datetime(2020, 9, 24, 16, 28, 15, 109810) dateString1 = dt.datetime.strftime(date1, '%Y-%m-%d %H:%M:%S') # '2020-09-24 16:28:15' 1. 2. 3. 2、日期格式–> 字符串(datet...
1、datetime.strptime() 首先strptime的函数命名不太好, 词义模糊, 不如直接叫str2time。string是source,time是result。 strptime(string, format) method of builtins.type instance string, format -> new datetime parsed from a string (like time.strptime()) #Case In [6]: datetime.strptime("8 May, 2...