0
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 (most recent call last): File "", line 3, in UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)解决的unicode输入字符串的文件中使用Unicode数据
在文本文件中的比较,我有大量尼泊尔的Unicode的。
我在这里比较两个unicode字符串做错了吗?
如何打印匹配的unicode字符串?
谢谢string1 = u“मनेपालीहुँ”解决了我的情况。对于string1 = string1.split()[0] [0]创建的问题..谢谢 –
你能帮我打印匹配的字符串吗? –