Lea*_*yra 3 python string character utf-8 capitalize
我一直试图大量加载字符串,其中一些以utf-8字符开头.问题是,他们没有大写!
mystring = 'lucas'
mystring.capitalize() # returns 'Lucas'
mytring = 'æthelred'
mystring.capitalize() # returns 'æthelred'
Run Code Online (Sandbox Code Playgroud)
与含有''^¨和字符ð,þ等的元音相同我该怎么做才能解决这个问题?
我实际上无法访问字符串,我将它们放在其他地方,在文本文件中......
你省略了u.字符串需要定义为python的unicode!
>>> mytring = u"æthelred"
>>> print mytring.capitalize()
Æthelred
Run Code Online (Sandbox Code Playgroud)
因为python 3字符串是unicode默认情况下你不需要u.
>>> "æthelred".capitalize()
'Æthelred'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
551 次 |
| 最近记录: |