我正在尝试做一个国际象棋棋盘,但是当谈到黑色方块时,我得到了以下错误:
File "C:\Users\Pedro\Dropbox\Aplicativos\NONIOInforestudante\Licenciatura em BioquÝmica\2015 2016\2.║ Semestre\Computadores e ProgramaþÒo\graph\f10-p1.py", line 17
yi = margem+((a-1)*(largura/8))
^
SyntaxError: invalid syntax
Press any key to continue . . .
这是代码:
#from graphics import *
import graphics
largura = 500
comprimento = 500
margem = 20
janela = graphics.GraphWin('Janela', comprimento+2*margem, largura+2*margem)
janela.setBackground('grey')
c = graphics.Rectangle(graphics.Point(margem, margem), graphics.Point(comprimento+margem,largura+margem))
c.setFill('white')
c.setOutline('black')
c.setWidth(1)
c.draw(janela)
for a in range(1,8,2):
xi = margem+(a*(comprimento/8)
yi = margem+((a-1)*(largura/8))
xf = margem+(a*((comprimento/8)*2)
yf = margem+(a*largura/8)
c = graphics.Rectangle(graphics.Point(xi, yi),graphics.Point(xf, yf)
c.setFill('black')
c.draw(janela)
janela.getMouse()
janela.close
你能解释一下我的问题是什么吗?
答案 0 :(得分:1)
在xi = margem+(a*(comprimento/8)
行中,你缺少一个结束括号。
试
xi = margem+(a*(comprimento/8))