python怎麼安裝turtle

(*-*)浩
發布: 2019-07-03 14:43:31
原創
25534 人瀏覽過

turtle庫是Python語言中一個很流行的繪製圖像的函數庫,想像一個小烏龜,在一個橫軸為x、縱軸為y的坐標係原點,(0,0)位置開始,它根據一組函數指令的控制,在這個平面座標系中移動,從而在它爬行的路徑上繪製了圖形。

python怎麼安裝turtle

安裝turtle(推薦學習:Python影片教學

Python2安裝指令:

pip install turtule
登入後複製

Python3安裝指令:

pip3 install turtle
登入後複製

繪圖範例

#太陽花

import turtle as timport time
t.color("red", "yellow")
t.speed(10)
t.begin_fill()for _ in range(50):
    t.forward(200)
    t.left(170)
end_fill()
time.sleep(1)
登入後複製

繪製五角星

import turtleimport time

turtle.pensize(5)
turtle.pencolor("yellow")
turtle.fillcolor("red")

turtle.begin_fill()for _ in range(5):
    turtle.forward(200)
    turtle.right(144)
turtle.end_fill()
time.sleep(2)

turtle.penup()
turtle.goto(-150,-120)
turtle.color("violet")
turtle.write("Done", font=('Arial', 40, 'normal'))
time.sleep(1)
登入後複製

更多Python相關技術文章,請造訪Python教學欄位進行學習!

以上是python怎麼安裝turtle的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!