python xxxx年xx月xx日转换成日期 xxxx-xx-xx

1 text是xxxx年xx月xx日

re.sub('年月','-',text[:-1]).

 

2

import time
def datetrans(text):
    dates = time.strptime(text, "%Y年%m月%d日")
    return time.strftime("%Y-%m-%d", dates)

 

posted @ 2019-11-27 10:51  jackduan1  阅读(2714)  评论(0编辑  收藏  举报