首页 > 编程语言 > 详细

python re.sub

时间:2018-03-17 10:36:29      阅读:212      评论:0      收藏:0      [点我收藏+]
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<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})",r"\g<month>/\g<day>/\g<year>",str1)
#‘10/15/2017 this is happy day...‘

 

python re.sub

原文:https://www.cnblogs.com/howhy/p/8587559.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!