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]創建的問題..謝謝 –
你能幫我打印匹配的字符串嗎? –