在输出上创建一个字符串。输出是一个 NoneType 对象

Create a string on the output. The output is a NoneType object

我正在运行宁基于方面的情感分析。我得到了输出。我想将此输出作为字符串。我花了几个小时在谷歌上搜索如何引用输出,而不仅仅是在 运行 代码时查看输出。也许我不理解 Python 基础知识,需要大量支持。

我说的代码如下:

absa.summary(money)

我从此代码收到的输出:

Sentiment.positive for "money"
Scores (neutral/negative/positive): [0.001 0.006 0.993]
None

我检查了这个对象的类型,它说 Nonetype:

type(absa.summary(money))
Sentiment.positive for "money"
Scores (neutral/negative/positive): [0.001 0.006 0.993]
NoneType

如何从输出中提取文本作为字符串?有任何想法吗?我会在需要时提供任何其他信息。

看起来该命令只是将输出打印到 stdout,而不是实际返回包含您要查找的信息的对象。您可能想尝试捕获 stdout 而 运行 函数。 this question 的回答应该会有帮助。