大家好,给大家分享一下python画笑脸步骤的中文翻译,很多人还不知道这一点。下面详细解释一下。现在让我们来看看!
前言
其实在学校没学过Python,只不过这次疫情在家着实有点闲,所以就借机看了看Python。就感觉python太强了,而且在实现相同效果下更简单python自动化运维系统。学过C,C++和C#,python我感觉算是最简单的了(可能是因为我接触的少吧)。看了mooc上的一些视频,就开始展示展示吧。
第一次学的库就是海龟(turtle)库,感觉即好玩又简单,所以就写了这个小画。看着简单,其实也费了一些力气。以后熟悉了就再画点好玩的吧!
一、介绍
使用平台:VS 2019(含Python3.7)
使用库:标准库turtle
二、演示效果
三、代码
import turtle
turtle.setup(800,800)
turtle.speed(10)
turtle.color("yellow")#画脸
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()
turtle.left(90)#画嘴
turtle.fd(15)
turtle.right(90)
turtle.color("yellow")
turtle.circle(175,270)
turtle.color("black")
turtle.circle(175,180)
turtle.color("yellow")
turtle.penup()
turtle.circle(175,270)
turtle.pendown()
turtle.color("yellow")
turtle.goto(-179,258)#左白眼
turtle.color("black")
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(20,25)
turtle.circle(-170,50)
turtle.circle(13,175)
turtle.circle(150,38)
turtle.circle(280,13)
turtle.end_fill()
turtle.goto(-179,258)
turtle.seth(0)
turtle.color("black")
turtle.begin_fill()
turtle.circle(16)
turtle.end_fill()
turtle.color("yellow")
turtle.goto(26,258)
turtle.color("black")
turtle.fillcolor("white")#右白眼
turtle.begin_fill()
turtle.circle(20,25)
turtle.circle(-170,50)
turtle.circle(13,175)
turtle.circle(150,38)
turtle.circle(280,13)
turtle.end_fill()
turtle.goto(26,258)#右黑眼坐标
turtle.seth(0)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(16)
turtle.end_fill()
turtle.pencolor("black")#右眉毛
turtle.penup()
turtle.goto(60,338)#右眉毛尖坐标
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.seth(25)
turtle.circle(-90,34)
turtle.seth(-25)
turtle.circle(-150,30)
turtle.left(155)
turtle.circle(80,55)
turtle.circle(60,80)
turtle.end_fill()
turtle.pencolor("black")#左眉毛
turtle.penup()
turtle.goto(-53,338)
turtle.pendown()
turtle.fillcolor("black")
turtle.begin_fill()
turtle.seth(155)
turtle.circle(90,34)
turtle.seth(205)
turtle.circle(150,30)
turtle.left(-155)
turtle.circle(-80,55)
turtle.circle(-60,80)
turtle.end_fill()
turtle.penup()
turtle.color("yellow")
turtle.fd(10)
turtle.done()
ircle(-60,80)
turtle.end_fill()
turtle.penup()
turtle.color("yellow")
turtle.fd(10)
turtle.done()