“TypeError: 'dict_keys' object is not subscriptable”
程序员文章站
2022-07-14 23:49:47
...
问题出在《Python自然语言处理》第18页的代码
属于python3会出现的情况
改为如下即可:
from nltk.book import *
fdist1=FreqDist(text1)
vocabulary1=fdist1.keys()
vocab=list(vocabulary1)
print("vocabulary1=",vocab)
fdist1.plot(50,cumulative=True)
推荐阅读
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#
-
TypeError: POST data should be bytes, an iterable of bytes, or a file object.制作有道翻译小翻译软件的问题解决方法
-
解决报错:TypeError: argument should be integer or bytes-like object, not ‘str‘
-
编译安卓源码提示:TypeError: argument should be integer or bytes-like object, not ‘str‘
-
TypeError: The value of a feed cannot be a tf.Tensor object.几种情况
-
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
-
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type s
-
TypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type s
-
“TypeError: 'dict_keys' object is not subscriptable”