【发布时间】:2020-08-17 00:48:03
【问题描述】:
当我在 python 2.7 CLI 中执行以下代码时
import nltk
它显示以下错误
SyntaxError:Invalid Syntax
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nani/.local/lib/python2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.collocations import *
File "/home/nani/.local/lib/python2.7/site-packages/nltk/collocations.py", line 35, in <module>
from nltk.probability import FreqDist
File "/home/nani/.local/lib/python2.7/site-packages/nltk/probability.py", line 333
print("%*s" % (width, samples[i]), end=" ") ^
SyntaxError: invalid syntax
如何解决这个问题?
【问题讨论】:
-
NLTK 不支持 Python 2。
标签: python python-2.7 syntax syntax-error nltk