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...'

 

相关文章:

  • 2021-12-30
  • 2021-08-03
  • 2021-08-09
  • 2021-07-28
  • 2022-12-23
猜你喜欢
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
  • 2022-03-03
相关资源
相似解决方案