怎么用python实现画笑脸


本文摘自php中文网,作者尚,侵删。

在Python中画笑脸可以使用turtle库实现。

1、打开idel,通过idel新建一个py文件,在空白的文件中输入下面的代码按F5运行此文件就可以画笑脸了。

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

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

from turtle import *

screensize(600,600)

speed(10)

  

#笑脸的小圆脸

pensize(5)

color('dim grey','yellow')

pu()

goto(0,-100)

begin_fill()

circle(100)

end_fill()

  

#腮红

#左侧

seth(90)

color('Light Pink','Light Pink')

pu()

goto(-55,-5)

pd()

begin_fill()

circle(20)

end_fill()

#右侧

color('Light Pink','Light Pink')

pu()

goto(55,-5)

pd()

begin_fill()

circle(-20)

end_fill()

  

#笑脸的眼睛

#左眼

color('dim grey','white')

pu()

goto(-10,22)

pd()

begin_fill()

circle(25)

end_fill()

#左瞳

color('dim grey','dim grey')

pu()

goto(-10,22)

seth(90)

pd()

begin_fill()

circle(25,-180)

end_fill()

#右眼

color('dim grey','white')

pu()

goto(10,22)

seth(90)

pd()

begin_fill()

circle(-25)

end_fill()

#右瞳

color('dim grey','dim grey')

pu()

goto(10,22)

seth(90)

pd()

begin_fill()

circle(-25,-180)

end_fill()

  

#笑脸的嘴巴

#左

pu()

goto(-4,-43)

seth(80)

pd()

circle(16,-200)

#右

pu()

goto(4,-43)

seth(110)

pd()

circle(-16,-185)

#连接

pu()

goto(4,-43)

seth(90)

pd()

circle(4,180)

  

hideturtle()

2、运行结果如下:

阅读剩余部分

相关阅读 >>

linux下修改Python命令的方法示例(附代码)

Python学习法则

验证码的随机生成

Python爬虫多少线程合适

Python之spider

Python怎么打开文件的路径?

Python list的常用方法

内置基于类的通用视图

Python能做什么游戏

django学习制作网页实例

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...