【发布时间】:2020-05-05 04:51:42
【问题描述】:
我在 python 中遇到重音问题
我写了 # -- coding: utf-8 -- 所以它可以识别重音。 但有时它仍然不起作用。我得到'?当我在收到错误“SyntaxError: Non-ASCII character '\xc3'”后使用它时
为什么?我应该改变什么?谢谢
(不适用于所有字符 'à','ç','é','è','ê','ë','î','ô','ù',"' ","'")
这是我的代码:
# -*- coding: utf-8 -*-
testList = ['à','ç','é','è','ê','ë','î','ô','ù',"‘","’"]
testCharacter = raw_input('test a character : ') # example : é
print(testCharacter) # getting é
print(testCharacter[0]) # getting ?
print(testCharacter + testCharacter[0]) # getting é?
testCharacterPosition = testList.index(testCharacter)
print(testCharacterPosition) #getting 2
这是我控制台上的结果:
test a character : é
é
?
é?
2
【问题讨论】:
-
为什么在 Python 3 中使用
raw_input()? -
看起来你是个初学者,那你为什么要使用已经报废的 Python 2?
标签: python utf-8 diacritics