The turtle python library knowledge and learning (5) of the difference between the export module

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_40840880/article/details/102761737

1. Basic export
import turtle

2. Export parameters
import turtle as t

3. wildcard export
from turtle import *

4. The above distinguish three export, that is to write the code more concise.

5. For example:
Code a:

Import Export turtle turtle # module
turtle.penup () # beginners may be better appreciated, can also be written turtle.pu ()
turtle.pensize (. 4)
turtle.pendown () # turtle.pd ()

Two codes:
Import Turtle T AS
t.penup () can also be written as # t.pu ()
t.pensize (. 4)
t.pendown () can also be written as # t.pd ()

Code three:
from Turtle Import *
penUp () # abbreviation PU ()
Pensize (R) (. 4)
penDown () # abbreviated PD ()

Code Example 6:

#导出模块
from turtle import*
#定义设置
setup(750,500)#设置窗口大小,位于电脑屏幕中心位置
pu()#提笔,为penup的缩写
pensize(25)#笔头大小为25
pencolor("pink")#画笔颜色为粉红色
fd(-230)
seth(90)
pd()#落笔,为pendown的缩写
circle(-50,180)
circle(50,-180)
circle(75,-50)
circle(-190,-45)
pu()
fd(185)
seth(180)
fd(120)
seth(90)
pd()
circle(-75,-50)
circle(190,-45)
pu()
fd(184)
seth(0)
fd(80)
seth(90)
pd()
circle(-50,180)
circle(50,-180)
circle(75,-50)
circle(-190,-45)
pu()
fd(185)
seth(180)
fd(120)
seth(90)
pd()
circle(-75,-50)
circle(190,-45)
#横右箭头
pu()#提笔
fd(150)
seth(180)#角度180度,水平位置
fd(300)
pencolor("red")#画笔颜色为红色
pensize(10)#画笔速度
pd()#落笔,且画出线条
fd(-500)
seth(90)
fd(30)
fd(-60)
seth(30)
fd(60)
seth(150)
fd(60)
done() #结束

7. After operation using FIG python3
Here Insert Picture Description

carry out. Welcome to the discussion.

Guess you like

Origin blog.csdn.net/weixin_40840880/article/details/102761737
Recommended