python怎么安装turtle-Python教程

资源魔 27 0
turtle库是Python言语中一个很盛行的绘制图象的函数库,设想一个小乌龟,正在一个横轴为x、纵轴为y的坐标系原点,(0,0)地位开端,它依据一组函数指令的管制,正在这个立体坐标系中挪动,从而正在它匍匐的门路上绘制了图形。

装置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的具体内容,更多请存眷资源魔其它相干文章!

标签: Python python教程 python编程 python使用问题

抱歉,评论功能暂时关闭!