本文摘自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、运行结果如下:
阅读剩余部分
相关阅读 >>
Python怎么模拟点击网页按钮
Python中open函数的用法详解
Python2.7和3.5兼容吗
如何实现Python冒泡排序算法?
Python脚本如何输入成绩求平均分?
词向量嵌入的实例详解
爬虫问题解决的相关问题
Python自学要多久能学会
Python和java环境变量冲突吗
实用自动化运维Python脚本分享
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 怎么用python实现画笑脸