问题描述
我是Python的新手。
目前我正试图将unicode角色转换成他的大写
非重音字符。
例如,使用语言环境fr_FR:
a,A,à,à应返回A
o,O,? ,?应该返回O
?,?应该回来吗?
我,我,?,?应该返回我
你有什么建议吗?
谢谢。
Hi,
I''am very newbie in Python.
For the moment I''am trying to convert an unicode character to his uppercase
unaccented character.
By example with locale fr_FR:
a,A,à,à should return A
o,O,?,? should return O
?,? should return ?
i,I,?,? should return I
Have you some suggestions ?
Thank.
推荐答案
Unicode字符串有一个upper()方法 - 试试看。我认为
应该适合您的语言环境 - 对于我来说,使用英语语言环境并没有给出预期的
结果。
Unicode strings have an upper() method - try that. I''m think it
should work properly with your locale - it doesn''t give the expected
result for me with an english locale.
Unicode字符串有一个upper()方法 - 尝试一下。我认为
应该适合您的语言环境 - 对于我来说,使用英语语言环境并没有给出预期的
结果。
Unicode strings have an upper() method - try that. I''m think it
should work properly with your locale - it doesn''t give the expected
result for me with an english locale.
不,这将使字符串大写,但它不会(也不应该)剥离
重音符号:
No, that will uppercase the string, but it doesn''t (and shouldn''t) strip
the accents:
a,A,à,à应返回A
o,O,?,?应该返回O
?,?应该回来吗?
我,我,?,?应该返回我''''
a,A,à,à should return A
o,O,?,? should return O
?,? should return ?
i,I,?,? should return I''''''
通过示例与LOCALE FR_FR:
A,A,à,à应该返回
O,O,?,?应该退还O $ / $
?,?应该回来吗?
我,我,?,?应该返回我
BY EXAMPLE WITH LOCALE FR_FR:
A,A,à,à SHOULD RETURN A
O,O,?,? SHOULD RETURN O
?,? SHOULD RETURN ?
I,I,?,? SHOULD RETURN I
我想也许我的新阅读器损坏了第三行。当我发送它时,它可能会腐蚀所有其他人。
I guess maybe my newreader corrupted the third line. It probably corrupts
all the others when I send this.
此新闻组中Google以bussiere开头的线程在2006-03-25关于或者
。 Fredrik Lundh提供的代码片段应该
帮助你。
Google in this newsgroup for a thread started by "bussiere" on or
about 2006-03-25. The code snippet provided by Fredrik Lundh should
help you.
这篇关于转换大写的unaccentent unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!