技术
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)
勤學如春起之苗,不見其增,日有所長。綴學如磨刀之石,不見其損,日有所虧。
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)