人生苦短 我用python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

import turtle #导入海龟库
turtle.setup(650,350,200,200) # 设置画布 长 宽 与屏幕左上角相距坐标
turtle.penup() # 海龟飞起
turtle.forward(-250) # 海龟后退
turtle.pendown() # 海龟下降
turtle.pensize(20) # 画笔大小
turtle.color("red") # 画笔颜色
turtle.setheading(-40) # 海龟转向 绝对角度 相对于整个坐标系而言
for i in range (4): # 做4次循环
turtle.circle(40,80) # 画弧 圆心在海龟左边 半径为40像素 角度为80度
turtle.circle(-40,80) # 画弧 圆心在海龟右边 半径为40像素 角度为80度
turtle.circle(40,80/2) # 画弧 圆心在海龟左边 半径为40像素 角度为40度
turtle.forward(40) # 海龟前进
turtle.circle(16,180) # 画弧 圆心在海龟左边 半径为40像素 角度为80度
turtle.forward(40*2/3) # 海龟前进
turtle.down() # 手动关闭 否者程序执行完毕自动关闭