2
我正在寫一個腳本來從一個語料庫文件中讀取並查找後綴。由於在語料庫中有波斯語單詞,因此它是UTF-8編碼,但是當我使用波斯語後綴進行搜索時,我無法獲得結果,另一方面,英語結果很好。在Python中使用Unicode爲波斯語
from __future__ import unicode_literals
import nltk
import sys
for line in open("corpus.txt"):
for word in line.split():
if word.endswith('ب'):
print (word)
你的意思是什麼*我沒有結果*? – Kasramvd
和你的Python版本是什麼? (似乎你在Python 3),但我需要確定! – Kasramvd
我使用的是Python 3.4,實際上我沒有在shell中得到任何結果,就好像在語料庫中沒有任何詞語一樣,@Kasra –