另见:有人可以用 Python 解释 __all__ 吗?仅供参考,您可以添加 noinspection 注释以告诉 Pycharm 不要将其标记为未解析的引用:from 海龟进口 *#noinspection PyUnresolvedReferences前进(100)完毕()或者,禁用特定范围的检查.当然,严格来说,您应该遵循 PEP8 和 避免通配符导入:导入海龟乌龟.前进(100)乌龟.完成()The code below works perfectly, however, PyCharm complains about syntax error in forward(100)#!/usr/bin/pythonfrom turtle import *forward(100)done()Since turtle is a stanrd library I don't think that I need to do additional configuration, am I right? 解决方案 The forward() function is made available for importing by specifying __all__ in the turtle module, relevant part from the source code:_tg_turtle_functions = [..., 'forward', ...]__all__ = (_tg_classes + _tg_screen_functions + _tg_turtle_functions + _tg_utilities + _math_functions)Currently, pycharm cannot see objects being listed in module's __all__ list and, therefore, marks them as an unresolved reference. There is an open issue in it's bugtracker:Make function from method: update __all__ if existing for starred import usageSee also: Can someone explain __all__ in Python?FYI, you can add the noinspection comment to tell Pycharm not to mark it as an unresolved reference:from turtle import *#noinspection PyUnresolvedReferencesforward(100)done()Or, disable the inspection for a specific scope.And, of course, strictly speaking, you should follow PEP8 and avoid wildcard imports:import turtleturtle.forward(100)turtle.done() 这篇关于使用乌龟的 PyCharm 错误语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!