3
我在打印希伯来语单词时遇到问题。我使用的计数器模块,以 计数在我给定的文字(这是在希伯来语)的单词数。计数器确实计数了 这个词,并且标识了语言,因为我正在使用# -*- coding: utf-8 -*-
在python上使用希伯来文
问题是,当我打印我的计数器时,我得到了奇怪的符号。 (我使用的Eclipse) 这里是代码和印刷:
# -*- coding: utf-8 -*-
import string
from collections import Counter
class classifier:
def __init__(self,filename):
self.myFile = open(filename)
self.cnt = Counter()
def generateList(self):
exclude = set(string.punctuation)
for lines in self.myFile:
for word in lines.split():
if word not in exclude:
nWord = ""
for letter in word:
if letter in exclude:
letter = ""
nWord += letter
else:
nWord += letter
self.cnt[nWord]+=1
print self.cnt
裴安平:
Counter({'\xd7\x97\xd7\x94': 465, '\xd7\x96\xd7\x95': 432, '\xd7\xa1\xd7\x92\xd7\x95\xd7\xa8': 421, '\xd7\x94\xd7\x92\xd7\x91': 413})
关于如何打印词语的正确方法你知道吗?
可能是终端依赖 – keyser
对不起为了不指出这一点,我正在使用eclipse – Itzik984