希腊编码在PYTHON [英] Greek encoding in PYTHON

查看:125
本文介绍了希腊编码在PYTHON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试存储一个字符串,并在python中使用nltk进行标记化。但是我无法理解为什么在标记之后(它创建一个列表)我无法看到列表中的字符串。
任何人都可以帮助我是plz?

i'm trying to store a string and after tokenize it with nltk in python.But i cant understand why after tokenizing it ( it creates a list ) i cant see the strings in list.. Can anyone help me plz?

这是代码:

#a="Γεια σου"
#b=nltk.word_tokenize(a)
#b
['\xc3\xe5\xe9\xe1', '\xf3\xef\xf5']

我只想定期看到列表的内容。

I just want to be able to see the content of the list regularly..

提前Thx

推荐答案

你使用的是Python 2,未标注的引号表示字节,而不是字符字符串(如果您不确定差异,读取此)。或者切换到Python 3(已经修复),或者使用 u 前缀所有字符串,并打印字符串(而不是显示他们的 repr ,它在Python 2.x中有所不同):

You are using Python 2, where unprefixed quotes denote a byte as opposed to a character string (if you're not sure about the difference, read this). Either switch to Python 3, where this has been fixed, or prefix all character strings with u and print the strings (as opposed to showing their repr, which differs in Python 2.x):

>>> import nltk
>>> a = u'Γεια σου'
>>> b = nltk.word_tokenize(a)
>>> print(u'\n'.join(b))
Γεια
σου

这篇关于希腊编码在PYTHON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆