如何使用python实现画笑脸

发布时间:2020-09-22 14:36:25 作者:小新
来源:亿速云 阅读:1838

这篇文章主要介绍如何使用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实现画笑脸的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. 怎么使用HTML5中的Canvas绘制笑脸
  2. 用python实现画爱心的方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python 笑脸

上一篇:如何才算精通C语言

下一篇:python定义一个变量的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》