【问题标题】:Missing module docstring (missing-module-docstring)缺少模块文档字符串 (missing-module-docstring)
【发布时间】:2023-01-03 11:27:35
【问题描述】:

我在 jupyter 中运行在两个数字的加法下面

'''
This program `summationoftwonumbers` and displays their results
'''

A = 1

B = 5

print('Sum of Numbers:',A+B)

它运行良好,输出为"Sum of Numbers: 6"

但是当使用 PyLint 运行文件时,summationoftwonumber.ipynb 会出现以下错误。

summationoftwonumbers.ipynb:1:0: C0114: Missing module docstring (missing-module-docstring)
summationoftwonumbers.ipynb:1:0: W0104: Statement seems to have no effect (pointless-statement)

我不明白为什么会这样。

【问题讨论】:

  • 如果您提供代码栅栏,那就太好了。

标签: python-3.x pylint docstring


【解决方案1】:

这是您使用引号来写评论,在某些情况下会创建 docstring。 Python 警告您该语句对您的程序无效。要摆脱警告,您可以重写该行:

''' This program summationoftwonumbers and displays their results '''

作为正常评论:

# This program summationoftwonumbers and displays their results 

【讨论】:

  • 我认为这不是您所说的尝试过的问题,但会出现相同的错误注意:我的意图是使用文档字符串