pygame导入问题 Module 'pygame' has no 'init' member

VScode+python导入pygame模板时会出现如下的错误(但是又能正常运行,弹出窗口):

pygame导入问题 Module 'pygame' has no 'init' member_第1张图片

它与Visual Studio Code按字面意思获取代码的事实有关,因为你无法导入pygame.init(),它认为它不是一个正确的模块。 要解决此问题,请打开settings.json(方法1:按ctrl+shift+p,搜索"setting",选择“首选项:打开设置(json)”。方法2:文件->首选项->设置->搜索栏搜索"python"->点击“在setting.json中编辑”。)并粘贴

"python.linting.pylintArgs": [ "----extension-pkg-whitelist=1xml" ],

pygame导入问题 Module 'pygame' has no 'init' member_第2张图片

然后错误就消失了。

你可能感兴趣的:(Python,python,pygame,导入,安装)