import res = 'birthday is 1991-11-19'res1 = re.sub('(\d{4})-(\d{2})-(\d{2})',r'\2/\3/\1',s)res2 = re.sub('(?P\d{4})-(?P \d{2})-(?P \d{2})',r'\g /\g /\g ',s)print(res1)print(res2)
本文共 352 字,大约阅读时间需要 1 分钟。
import res = 'birthday is 1991-11-19'res1 = re.sub('(\d{4})-(\d{2})-(\d{2})',r'\2/\3/\1',s)res2 = re.sub('(?P\d{4})-(?P \d{2})-(?P \d{2})',r'\g /\g /\g ',s)print(res1)print(res2)
转载于:https://www.cnblogs.com/ray-mmss/p/10465741.html