View source method, slightly.
First, the discovery questions
test
import turtle as t
print(type(t))#打印t的类型
t.forward(100)#使用海归的方法
t.done()#阻止窗口关闭
result:
Question: Why is the module type, able to call the returnees method?
Second, the source answer
1.import turtle introduced is the name for the turtle.py files, there are a lot of categories, including Class Turtle
Knowledge Development: the difference between Python modules, packages and libraries https://blog.csdn.net/tscaxx/article/details/103680363
2.Turtle class inside the method into a global methods , so you can use methods like turtle module .Turtle
Source Inside, the two global methods, the turtle module _Screen, in some ways Turtle turned into a global approach. Execution time class loading.
3 corresponds to the default module turtle which have an object class Turtle . We can also create a lot of Turtle object.
import turtle as t
print(type(t))#打印t的类型
t.forward(100)#默认的Turtle对象
t1 = t.Turtle()#创建第一个Turtle对象t1
t1.right(90)
t1.forward(100)
t2 = t.Pen()#创建第二个Turtle对象t2
t2.right(-90)
t2.forward(100)
result:
Description:
t.Turtle () and t.Pen () as
Source Analysis:
Third, continued. . . . .