python中seth和fd_python的turtle库认识和学习(5)之模块导出区别

1.基本导出

import turtle

2.参数导出

import turtle as t

3.通配符导出

from turtle import*

4.以上三种导出的区别,即代码编写越来越简洁。

5.比如:

代码一:

import turtle#导出turtle模块

turtle.penup()#初学者可能好理解,也可写成turtle.pu()

turtle.pensize(4)

turtle.pendown()#turtle.pd()

代码二:

import turtle as t

t.penup()#也可写成t.pu()

t.pensize(4)

t.pendown()#也可写成t.pd()

代码三:

from turtle import*

penup()#简写pu()

pensize(4)

pendown()#简写pd()

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() #结束1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

7.用python3运行之后的图

f93a7655e12254aa16c6ae23b97a5170.png

完成。欢迎讨论。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值