【问题标题】:PyLint not recognizing mainloop() member of the turtle modulePyLint 无法识别海龟模块的 mainloop() 成员
【发布时间】:2021-05-29 20:23:59
【问题描述】:

我正在尝试 python 的 turtle 模块,虽然程序执行正确,但 PyLint 一直错误地将程序的某些部分标记为错误。程序polygon.py 包含以下内容:

import turtle 
t = turtle.Turtle() 
t.fd(100) 
turtle.mainloop() 

这个程序按预期执行,海龟向前移动了 100 像素。但是,在 VSCode 中,PyLint 将turtle.mainloop() 下划线表示为错误,表示:

Module 'turtle' has no 'mainloop' member pylint(no-member)

此外,在实际的turtle.py 模块中,提及mainloop() 以及其他一些成员也被标记为错误,表示:

"mainloop" is not defined Pylance (reportUndefinedVariable) 

我尝试卸载并重新安装 PyLint,但仍然显示错误。我该如何修复它们,或者至少考虑到程序可以正常工作来隐藏它们?

【问题讨论】:

    标签: python tkinter python-turtle


    【解决方案1】:

    经过一番搜索,我找到了解决误报 no member 错误的方法。对于 PyLint,转到相应的 JSON 文件并添加:

    "python.linting.pylintArgs":[
            "--generated-members"
    ]
    

    代表问题作者添加。

    【讨论】:

      猜你喜欢
      • 2019-06-23
      • 2019-06-02
      • 1970-01-01
      • 2019-01-12
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      相关资源
      最近更新 更多