str1="2017-10-15 this is happy day...">>> re.sub("(\d{4})-(\d{2})-(\d{2})",r"\2/\3/\1",str1)##'10/15/2017 this is happy day...'>>> re.sub("(?P\d{4})-(?P \d{2})-(?P \d{2})",r"\g /\g /\g ",str1)#'10/15/2017 this is happy day...'
本文共 396 字,大约阅读时间需要 1 分钟。
str1="2017-10-15 this is happy day...">>> re.sub("(\d{4})-(\d{2})-(\d{2})",r"\2/\3/\1",str1)##'10/15/2017 this is happy day...'>>> re.sub("(?P\d{4})-(?P \d{2})-(?P \d{2})",r"\g /\g /\g ",str1)#'10/15/2017 this is happy day...'
转载于:https://www.cnblogs.com/howhy/p/8587559.html