首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >预期的")“Pylance

预期的")“Pylance
EN

Stack Overflow用户
提问于 2021-05-27 02:35:11
回答 1查看 10.7K关注 0票数 3

我正在用python(Vs代码)编写代码,我有这个错误:

代码语言:javascript
复制
Expected ")"  Pylance 

错误发生在:def main()

我试着运行main并将其打印到屏幕上。我用谷歌搜索了一下,找不到任何解决方案。我怎么才能修复它呢?

这是我的代码:

代码语言:javascript
复制
#The main driver of our code , this will handle user input and updating the graphics 
def 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))
 

if __name__ == '__main__':
   main()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-27 14:13:13

代码语言:javascript
复制
p.transform.scale(p.image.load("image/" + piece + ".png"), (SQ_SIZE, SQ_SIZE)

你在(SQ_SIZE, SQ_SIZE)后面漏掉了一个右括号

代码语言:javascript
复制
p.transform.scale(p.image.load("image/" + piece + ".png"), (SQ_SIZE, SQ_SIZE))
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67710862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档