E1101:Module 'turtle' has no 'forward' member

最后都变了- 提交于 2020-07-19 01:58:27

问题


I'm new to programming and I downloaded Python and got it running in Visual Studio Code. I was messing around with the turtle module and its functions.

The functions themselves work but pylint marks it as an error and says that there isn't a "member" like what I coded.

How would I go about fixing this error? (I don't want to set it to "ignore" the issue but rather recognize that the code I'm typing in is valid and comes from the turtle module)


回答1:


The turtle module exposes two interfaces, a functional one and an object-oriented one. The functional interface is derived programatically from the object-oriented interface at load time, so static analysis tools can't see it, thus your pylint error. Instead of the functional interface:

import turtle

turtle.forward(100)

turtle.mainloop()

For which pylint generates no-member, try using the object-oriented interface:

from turtle import Screen, Turtle

screen = Screen()

turtle = Turtle()

turtle.forward(100)

screen.mainloop()

This particular import for turtle blocks out the functional interface and I recommend it as folks often run into bugs by mixing both the OOP and functional interaces.



来源:https://stackoverflow.com/questions/52902627/e1101module-turtle-has-no-forward-member

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!