# ----------------时间转字符串
dateTime_p = datetime.now() # 获取现在的时间
print(dateTime_p ,type(dateTime_p)) #<class 'datetime.datetime'>
str_p = datetime.strftime(dateTime_p,'%Y-%m-%d')
print(str_p ,type(str_p) ) # 转化为 字符串<class 'str'>
# 字符串转时间
str_p = '2022-08-06'
date_p = datetime.strptime(str_p,'%Y-%m-%d').date() # 转化为日期格式
print(date_p,type(date_p))#<class 'datetime.date'>