将中文日期转换成自己想要的格式如:2018年09月29日转换成2018-09-29

def date_conversion(self,date):
'''将中文日期转换成自己想要的格式如:2018年09月29日转换成2018-09-29'''
c = list(re.findall(r'(.*)年(.*)月(.*)日',date)[0])
print(c)
if len(c[1]) < 2:
c[1] = '0' + c[1]
print('-'.join(c))
new_date = '-'.join(c)
else:
print('-'.join(c))
new_date = '-'.join(c)
return new_date
原文地址:https://www.cnblogs.com/fh-fendou/p/9723780.html