【发布时间】:2015-11-08 14:14:11
【问题描述】:
string1=" म नेपाली हुँ"
string1=string1.split()
string1[0]
'\xe0\xa4\xae'
with codecs.open('nepaliwords.txt','r','utf-8') as f:
for line in f:
if string1[0] in line:
print "matched string found in file"
Traceback(最近一次调用最后一次):文件“”,第 3 行,in UnicodeDecodeError: 'ascii' 编解码器无法在位置解码字节 0xe0 0: 序数不在范围内(128)
在文本文件中,我有大量的尼泊尔语 unicode。
我在这里比较两个 unicode 字符串做错了吗?
如何打印匹配的 unicode 字符串?
【问题讨论】: