gzj137070928 发表于 2020-10-28 13:50:38

绘制蟒蛇图

绘制蟒蛇图
import turtle as t

t.setup(650, 350, 200, 200)
t.penup()
t.fd(-250)
t.pendown()
t.pensize(25)
t.pencolor("purple")
t.seth(-40)
for i in range(4):
    t.circle(40, 80)
    t.circle(-40, 80)
t.circle(40, 80/2)
t.fd(40)
t.circle(16, 180)
t.fd(40 * 2 / 3)
t.done()

LuLD 发表于 2020-10-28 14:24:50

这叫 龙回头 {:5_97:}

gzj137070928 发表于 2020-10-28 14:47:27

LuLD 发表于 2020-10-28 14:24
这叫 龙回头

ok{:5_95:}

小彭不会飞 发表于 2020-12-6 20:03:57

def drawSnake(rad, angle, len, neckrad):
    for i in range(len):
      turtle.circle(rad, angle)
      turtle.circle(-rad, angle)
    turtle.circle(rad, angle/2)
    turtle.fd(rad)
    turtle.circle(neckrad+1,180)
    turtle.fd(rad*2/3)


def main():
    turtle.setup(1300, 800, 0, 0)
    pythonsize = 30
    turtle.pensize(pythonsize)
    turtle.pencolor("bule")
    turtle.seth(-40)
    drawSnake(40,80,5,pythonsize/2)


main()
大佬,请问为啥我这个绘制蟒蛇会报错

gzj137070928 发表于 2020-12-7 09:43:36

小彭不会飞 发表于 2020-12-6 20:03
def drawSnake(rad, angle, len, neckrad):
    for i in range(len):
      turtle.circle(rad, angle ...

1、添加:import turtle
2、turtle.pencolor("bule")这里需要修改为turtle.pencolor(“blue”)
3、【可选项】在drawSnake(40,80,5,pythonsize/2)后面添加turtle.done():画图窗口不会自动关闭
页: [1]
查看完整版本: 绘制蟒蛇图