python 正则表达式--提取日期 替换IP为一个固定路径

import re
studyDate = '2018-08-09 12:10'
dateidentifier = studyDate[0:10]
pattern = re.compile(r'\d+')
temp = re.findall(pattern, dateidentifier)
date = "".join(temp)
print(date)

 
  


import re
path = r"\\127.0.0.1\dcm\tt\1.0.0.0"
pattern_move = re.compile(r'\\\\\d+\.\d+\.\d+\.\d+')
picroot = 'E:'
server_filepath , number = re.subn(pattern_move, picroot, path)
print(server_filepath)


你可能感兴趣的:(python 正则表达式--提取日期 替换IP为一个固定路径)