示例:字符转日期时间
方法一:datetime模块的strptime函数
datetime.strptime('2020-12-04','%Y-%m-%d')
#datetime.datetime(2020, 1, 2, 0, 4)方法二:pandas模块里面的to_datetime函数
import pandas as pd
pd.to_datetime('2020-12-04')
#Timestamp('2020-12-04 00:00:00')
pd.to_datetime('202012',format='%Y%m')
#Timestamp('2020-12-04 00:00:00')