怎么用python实现画笑脸

怎么用python实现画笑脸,第1张

概述怎么用python实现画笑脸

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

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

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教程栏目进行学习! 总结

以上是内存溢出为你收集整理的怎么用python实现画笑脸全部内容,希望文章能够帮你解决怎么用python实现画笑脸所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1157709.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-01
下一篇 2022-06-01

发表评论

登录后才能评论

评论列表(0条)

保存