安装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教程栏目进行学习!
Copyright © 2019- 517ttc.cn 版权所有 赣ICP备2024042791号-8
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务