美文网首页
python day 03

python day 03

作者: michaeljacc | 来源:发表于2016-06-05 22:40 被阅读30次

# 这表示引入了一个别人写好的东西(很快会讲)
import turtle
# 这样可以得到一个 t 变量, 可以对它进行很多操作
# 很快会讲, 现在先用t
 = turtle.Turtle()step = 50
# forward 表示向前走
# 刚开始的时候朝右, 并且在坐标 (0, 0)
t.forward(step)
# pen up 可以把笔抬起来, 这样往前走就不会画线了t.penup()t.forward(step)
# pen down 后又可以画线了
t.pendown()t.forward(step)
# left 可以往左转
t.left(90)
t.forward(step)
# pensize 可以改变线条粗细
# 建议不要太大
t.pensize(5)
# pencolor 可以设置颜色, 颜色的具体数值可以通过下面这个网页得到
# [http://tool.ganchang.cn/getcolortool.html](http://tool.ganchang.cn/getcolortool.html)
# 注意, 参数是一个字符串color='#55C2DD't.pencolor(color)
# right 可以右转
t.right(90)
t.forward(step)
# position 可以得到当前的坐标
pos = t.position()print('坐标是, ', pos)
# home 可以回到原点
# 利用 penup 可以无痕回到原点t.home()# 画完后一定要加上这一句turtle.done()
# 额外的一些功能
# 隐藏光标#
t.hideturtle()
## 显示光标# 
t.showturtle()

相关文章

网友评论

      本文标题:python day 03

      本文链接:https://www.haomeiwen.com/subject/snurdttx.html