查找正则表达式 import re re_txt = re.compile(r'(\d)*.txt') m = re_txt.search(src) if not m == None: m.group(0) #complete str m.group(1) # first group string 匹配正则表达式 if re.match(r'(\d)*.txt',path): print("match") else: print("not match") 分割正则表…
1.首字母大写 >>> s = 'yuanzhumuban' >>> s.capitalize() 'yuanzhumuban' 2.replace,替换 >>> s = 'my name is yuanzhumuban, age is 20' >>> s 'my name is yuanzhumuban, age is 20' >>> s.replace( '20', '30' ) 'my name is yua…