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)

猜你喜欢

转载自www.cnblogs.com/jackduan/p/11940506.html
xx