编程语言
首页 > 编程语言> > python绘制国际象棋棋盘核心代码

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()

标签:turtle,right,python,国际象棋,step,color,range,棋盘,fill
来源: https://www.cnblogs.com/zxfei/p/11930841.html