gpt4 book ai didi

python - 你如何修复 "Missing module docstringpylint(missing-module-docstring)"

转载 作者:行者123 更新时间:2023-12-04 14:35:18 34 4
gpt4 key购买 nike

我在 VSCode 上使用 pygame 模块,但遇到了 pygame 没有 init 成员的问题。我遵循了 this 的解决方案关联。我编辑了用户设置并添加了

    "python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame",
"--unsafe-load-any-extension=y"
]
到json文件的末尾
pygame 问题已解决。但是,当我使用 import random 时.我收到此警告:
缺少模块文档字符串pylint(缺少模块文档字符串)
我该如何让它消失?另外,有没有更好的方法来解决pygame的init问题?
谢谢!

最佳答案

python 模块的文档字符串记录了该文件的内容。
您可以通过在模块顶部添加文档字符串来解决此错误:

"""
Provides some arithmetic functions
"""

def add(a, b):
"""Add two numbers"""
return a + b

def mult(a, b):
"""Multiply two numbers"""
return a * b
阅读更多 https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings

关于python - 你如何修复 "Missing module docstringpylint(missing-module-docstring)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65949325/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com