问题背景

正在用VScode做turtle库的相关小练习,然后在运行程序时出现了报错
python Module turtle has no circle member解决办法
但是当我用python终端时却可以运行
python Module turtle has no circle member解决办法
python Module turtle has no circle member解决办法
百思不得其解的我就去百度了


原因阐述

python Module turtle has no circle member解决办法

pylint是vscode的python语法检查器,pylint是静态检查,在用第三方库的时候有些成员只有在运行代码的时候才会被建立,它就找不到成员

所以,当程序不运行的时候,vscode就找不到turtle模块,所以报错了

知识小拓展:Pylint 是一个 Python 代码分析工具,除了平常代码分析工具的作用之外,它提供了更多的功能:如检查一行代码的长度,变量名是否符合命名标准,一个声明过的接口是否被真正实现等等。


解决办法

按F1,进入setting.json
输入"python.linting.pylintArgs": ["–generate-members"]
python Module turtle has no circle member解决办法
保存即可
注:在前面那个语句后面加上逗号


PS:vscode运行turtle库的代码时,会运行完就关闭,可以加上turtle.done()代码

如有问题,请留言

相关文章: