首頁  >  文章  >  後端開發  >  怎麼用python實作畫笑臉

怎麼用python實作畫笑臉

尚
原創
2019-07-02 18:01:0317022瀏覽

怎麼用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實作畫笑臉的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn