0

使用 Anaconda Spyder、Python 3.8.3、nltk 3.5。下面的代码和输出:

from nltk.corpus import reuters
cfd = [('gas', word) for word in brown.words(categories='gas')]
print(cfd.tabulate(conditions=['gas'], samples=['gasoline', 'barrels']))

----------------
Output:
    gasoline  barrels 
gas       77       64 
None

如何从此输出中删除 None ?

仅供参考 - 当我使用 Jupyter 笔记本时,没有输出如下:

cfd = [('gas', word) for word in brown.words(categories='gas')]
cfd.tabulate(conditions=['gas'], samples=['gasoline', 'barrels']

----------------
Output:
    gasoline  barrels 
gas       77       64
4

1 回答 1

0

您不需要 print 来显示输出。只需使用

cfd.tabulate(conditions=['gas'], samples=['gasoline', 'barrels'])
于 2020-08-27T11:16:01.337 回答