I work with dictionary and I want to detect keys which contains non-english characters like 'č' for example.
This is my code:
for i in dictionaryMemory.keys():
czechChars=['á','é','í','ó','ů','ě','ř','ť','č','š','ž']
if any(s in i for s in czechChars):
dictionaryMemory.pop(i)
print(i)
But when I try to run this code, eclipse prints that SyntaxError: Non-ASCII character '\\xc3' in file...
Ok, so I try to put # -*- coding: utf-8 -*-
¨. It seems to work, but it can't find any of these characters. What to do?
EDIT: In the project properties I found this: Text file encoding: inherited from container(Cp1250)
I have a problems with encoding very usually but can't still figure out how to do it in a proper way...
就像Tal Kremerman和Mark Ransom所说的那样,我试图将编码注释从utf-8
更改为cp1250
,然后检查代码中的字符是否格式正确,所以没有,所以我将其更改为č,š,ř...
终于可以了!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.