sách gpt4 ai đã đi

python - mong đợi ")"

In lại 作者:行者123 更新时间:2023-12-04 14:07:05 26 4
mua khóa gpt4 Nike

nhập mô tả hình ảnh ở đây我正在用 python(Vs 代码)编写代码,但出现此错误:

Expected ")" Pylance 

错误发生在:def main()
我试着运行我的 main 并将它打印到我的屏幕上。我用谷歌搜索并找不到任何解决方案。我该如何解决?

Đây là mã của tôi:

#The main driver of our code , this will handle user input and updating the graphics 
định nghĩa main():

p.init ()
screen = p.display.set_mode((WIDTH,HEIGHT))
clock = p.time.Clock ()
screen.fill(p.Color("white"))
gs= ChessEngine.GameState()
print(gs.board)
loadImages() #only do this once, before the whille loop
running=True
while running :
for e in p.event.get():
if e.type == p.QUIT:
running =False

drawGameState(screen,gs)
clock.tick(MAX_FPS)
p.display.flip()

'''
Responsible for all the graphics within a currnet game state.
'''
def drawGameState(screen,gs):
drawBoard (screen) #draw squars on the board
#add in piece highlighting or move suggestions

drawPieces(screen,gs.board) #draw pieces on the top of those squares

'''
draw the squares on the board the top left square is always light

'''
def drawBoard(screen):
colors = [p.Color("white"), p.Color("gray")]
for r in range (DIMENSION):
for c in range (DIMENSION):
color = colors[((r+c) % 2)]
p.draw.rect(screen , color , p.Rect(c*SQ_SIZE,r*SQ_SIZE,SQ_SIZE_SQ_SIZE))

'''
draw the pieces on the board using the current Game.State.board
'''
def drawPieces(screen,board):
for r in range (DIMENSION):
for c in range (DIMENSION):
piece=board[r][c]
if piece != "--": #not empty squares
screen.blit(IMAGES[piece],p.Rect(c*SQ_SIZE,r*SQ_SIZE))


nếu __name__ == '__main__':
chủ yếu()

1 Câu trả lời

p.transform.scale(p.image.load("image/" + piece + ".png"), (SQ_SIZE, SQ_SIZE)

您在 (SQ_SIZE, SQ_SIZE) 之后错过了一个右括号>

p.transform.scale(p.image.load("image/" + piece + ".png"), (SQ_SIZE, SQ_SIZE))

关于python - 预期 ")",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67710862/

26 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com