python绘制国际象棋棋盘核心代码

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()
posted on 2019-11-25 21:56  行之间  阅读(2321)  评论(0编辑  收藏  举报