import turtle step = 40 for i in range(8): for j in range(8): turtle.penup() turtle.goto(i*step, j*step) turtle.pendown() turtle.begin_fill() if (i+j)%2 == 0: turtle.color("white") else: turtle.color("black") for k in range(4): turtle.forward(step) turtle.right(90) turtle.end_fill() turtle.done()
来源:https://www.cnblogs.com/zxfei/p/11930841.html