datetime
import datetime # 导入库
datetime.datetime.today()
获取当前时间
datetime.datetime.today()
处理为日期数据
datetime.datetime.today().date()
str转datetime.datetime
day1 = datetime.datetime.today().date()
day1.strftime("%Y%m%d")
datetime.datetime转str
datetime.datetime.strptime('20200101','%Y%m%d')
pandas.to_datetime
str转timestamps.Timestamp
pd.to_datetime("20200101")
timestamps.Timestamp转str
day2 = pd.to_datetime("20200101")
day2.strftime('%Y%m%d')
timestamps.Timestamp转datetime.date
day2.date()
timestamps.Timestamp查看周几
day2.day_name()
Out[44]: 'Wednesday'