参考博主点击此处可转参考文章
参考博主点击此处可转参考文章
使用 pycharm 编辑turtle画图时发现没有自动识别和提示,虽然不影响编辑程序,但却无法查看详细函数代码,
开始以为是turtle的库没有安装上,去pycharm的库里面查看发现库里面的turtle的版本是turtle–0.0.1,查了一下发现大家都是在用turtle–0.0.2,以为是版本过低导致的,就先升级一下版本。
turtle–0.0.2的下载地址 : 点击此处即可下载
(试了三个博主的,有的无法使用,有的需要进入到文件夹内部安装,结果也不行。这是第四个博主完全适用pycharm2019.2,python3.6版本)
下载安装包解压后,打开setup.py,将第40行代码修改为:
except (ValueError, ve):
执行如下安装命令:
pip install -e D:\InstallationPackage\turtle-0.0.2
-e后面是保存的turtle-0.0.2所在的目录
成功安装turtle-0.0.2后发现还是没有自动提示(头大),经过一阵搜索,终于找到解决办法。
打开 Python 安装路径下的lib库,找到turtle.py文件(turtle 库是 Python 标准库)或者如下图按住Ctrl鼠标左键点击turtle便能进入turtle.py文件
注释142,143行处的代码
#__all__ = (_tg_classes + _tg_screen_functions + _tg_turtle_functions +
# _tg_utilities + ['Terminator']) # + _math_functions)
追加
__all__ = ['ScrolledCanvas', 'TurtleScreen', 'Screen', 'RawTurtle', 'Turtle', 'RawPen', 'Pen', 'Shape', 'Vec2D', 'back',
'backward', 'begin_fill', 'begin_poly', 'bk', 'addshape', 'bgcolor', 'bgpic', 'bye', 'clearscreen',
'colormode', 'delay', 'exitonclick', 'getcanvas', 'getshapes', 'listen', 'mainloop', 'mode', 'numinput',
'onkey', 'onkeypress', 'onkeyrelease', 'onscreenclick', 'ontimer', 'register_shape', 'resetscreen',
'screensize', 'setup', 'Terminator', 'setworldcoordinates', 'textinput', 'title', 'tracer', 'turtles',
'update', 'window_height', 'window_width', 'write_docstringdict', 'done', 'circle', 'clear', 'clearstamp',
'clearstamps', 'clone', 'color', 'degrees', 'distance', 'dot', 'down', 'end_fill', 'end_poly', 'fd',
'fillcolor', 'filling', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly', 'getturtle', 'goto',
'heading', 'hideturtle', 'home', 'ht', 'isdown', 'isvisible', 'left', 'lt', 'onclick', 'ondrag', 'onrelease',
'pd', 'pen', 'pencolor', 'pendown', 'pensize', 'penup', 'pos', 'position', 'pu', 'radians', 'right', 'reset',
'resizemode', 'rt', 'seth', 'setheading', 'setpos', 'setposition', 'settiltangle', 'setundobuffer', 'setx',
'sety', 'shape', 'shapesize', 'shapetransform', 'shearfactor', 'showturtle', 'speed', 'st', 'stamp', 'tilt',
'tiltangle', 'towards', 'turtlesize', 'undo', 'undobufferentries', 'up', 'width', 'write', 'xcor', 'ycor']
结果如下:
保存退出,重新查看 turtle 库函数,发现已经能正常识别,而且可以智能提示