我正在使用此代码块:
>>> import re
>>> def titlecase(s):
... return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
... lambda mo: mo.group(0)[0].upper() +
... mo.group(0)[1:].lower(),
... s)
...
>>> titlecase("they're bill's friends.")
"They're Bill's Friends."
它来自Python的文档。在
如果字符串包含一个土耳其语字符,比如'o',string将变成
“雷布”。为了支持所有语言,我应该写些什么?在
使用Unicode字符属性数据库,通过使用
flags=re.UNICODE
编译正则表达式:在python2上,需要使用Unicode字符串:
^{pr2}$使用unicode字符串,即
titlecase(u'börek')
。在相关问题 更多 >
编程相关推荐