• pycharm turtle无法识别turtle. 没有自动提示


     PyCharm 中写 Turtle代码没提示以及标黄问题

    PyCharm 中在使用Turtle(海龟)库绘图体系时,代码明明是正确可以运行的,但是没有提示代码出现黄色标记以及红色波浪线

    原因
    pycharm和turtle库有冲突,不能自己识别出turtle下的方法:


    解决方案
    找到  turtle.py 
    你可以对turtle库的源码进行如下修改:
    注释掉原来的_ all_ ,新增如下:

    # __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']

      

    pycharm对turtle的画布悬停解决方案

    在用python自带的IDLE中,turtle运行后的画布是可以停留的。而pycharm中一闪而过,需要在代码后面加上如下即可悬停:

    import turtle

    turtle.setup(800, 800)

    # pycharm需要加的内容
    turtle.done()

    链接:https://blog.csdn.net/s740556472/article/details/79947956

  • 相关阅读:
    Oracle11g远程连接配置 visual studio 2003
    窗体设计器的使用套件
    Visual Studio 2003“无法启动调试 没有正确安装调试器“请修复调试器的解决办法
    eclipse maven插件安装教程
    遇到错误ERROR 1044 (42000): Access denied for user ''@'localhost'to database 'mysql',的解决办法
    定位
    盒子模型
    CSS3美化网页元素
    CSS随笔
    前端基础随笔
  • 原文地址:https://www.cnblogs.com/emanlee/p/15738223.html
Copyright © 2020-2023  润新知