解決PyCharm 中寫 Turtle代碼沒提示以及標(biāo)黃的問題
PyCharm 中在使用Turtle(海龜)庫繪圖體系時,代碼明明是正確可以運(yùn)行的,但是沒有提示 ,代碼出現(xiàn)黃色標(biāo)記以及紅色波浪線 ,經(jīng)驗(yàn)不足的人還以為自己的書寫方法錯誤,畢竟出現(xiàn)了紅色波浪線,效果如下圖:

原因說明:
出現(xiàn)這個問題往往可能并不是你的問題,而是pycharm和turtle庫有沖突 ,不能自己識別出turtle下的方法,站在pycharm本身的角度下它覺得你的代碼出錯了 ,找不到,所以給你標(biāo)紅線,標(biāo)黃色標(biāo)記:
解決方案:
點(diǎn)擊到turtle.py源文件中,對turtle庫的源代碼進(jìn)行如下修改,注釋掉原來的_ all_,復(fù)制下面的代碼, 效果圖如下

__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']
修改效果:

補(bǔ)充:pycharm 部分解決 pycharm 代碼無提示的問題 添加對象聲明
各位python的童鞋在日常使用pycharm的過程中是否同樣碰到代碼無提示的難受情況,
下面介紹通過類型聲明的方式解決一部分提示問題,
實(shí)例
def index(request:HttpRequest): # 形參設(shè)置對象類型,:后跟類名
# 變量定義時聲明
template = loader.get_template("index.html") # type : Template
template.render() # 經(jīng)測試可解決此處template 無提示的情況
以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。如有錯誤或未考慮完全的地方,望不吝賜教。
相關(guān)文章
Windows下安裝python2.7及科學(xué)計算套裝
這篇文章主要向大家介紹的是在windows系統(tǒng)下安裝python 2.7以及numpy安裝、six安裝、dateutil安裝、pyparsing安裝、matplotlib安裝和scipy安裝的方法,分享給大家,需要的小伙伴可以參考下,相對來說,windows下的安裝還是比較簡單的。2015-03-03
PYQT5 實(shí)現(xiàn)給listwidget的滾動條添加滾動信號
這篇文章主要介紹了PYQT5 實(shí)現(xiàn)給listwidget的滾動條添加滾動信號,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-03-03
python命令行參數(shù)argparse模塊基本用法詳解
argparse?是python自帶的命令行參數(shù)解析包,可以用來方便地讀取命令行參數(shù),這篇文章主要介紹了python命令行參數(shù)-argparse模塊基本用法,需要的朋友可以參考下2023-01-01
使用 PyTorch 實(shí)現(xiàn) MLP 并在 MNIST 數(shù)據(jù)集上驗(yàn)證方式
今天小編就為大家分享一篇使用 PyTorch 實(shí)現(xiàn) MLP 并在 MNIST 數(shù)據(jù)集上驗(yàn)證方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01

