import re
pattern=re.compile(r"(\w+)(\w+)")
string="i say, hello world"
def func(m):
return m.group(1).title()+''+m.group(2).title()
print re.sub(pattern,func,s)
转载于:https://www.cnblogs.com/ITniu/p/6424200.html
import re
pattern=re.compile(r"(\w+)(\w+)")
string="i say, hello world"
def func(m):
return m.group(1).title()+''+m.group(2).title()
print re.sub(pattern,func,s)
转载于:https://www.cnblogs.com/ITniu/p/6424200.html