https://pastebin.com/TZdMx3pM 这是代码
此错误在第291行出现:
import pygame
pygame.init()
win = pygame.display.set_mode((500,500))
clock= pygame.time.Clock()
x= 50
y=450
width=64
height=64
vel=5
left = False
right = False
iJ=False
jC=10
walkcount = 0
pygame.display.set_caption("Karifa Game")
walkright = [pygame.image.load('R1.png'), pygame.image.load('R2.png'), pygame.image.load('R3.png'), pygame.image.load('R4.png'), pygame.image.load('R5.png'), pygame.image.load('R6.png'), pygame.image.load('R7.png'), pygame.image.load('R8.png'),pygame.image.load('R9.png')]
walkleft = [pygame.image.load('L1.png'), pygame.image.load('L2.png'), pygame.image.load('L3.png'), pygame.image.load('L4.png'), pygame.image.load('L5.png'), pygame.image.load('L6.png'), pygame.image.load('L7.png'), pygame.image.load('L8.png'),pygame.image.load('L9.png')]
bg = pygame.image.load('bg.jpg')
char = pygame.image.load('standing.png')
run = True
def redrawGameWindow():
global walkcount
win.blit(bg, (0,0))
if walkcount + 1 >= 27:
walkcount = 0
if left:
win.blit(walkleft[walkcount//3])
walkcount += 1
elif right:
win.blit(walkright[walkcount//3])
walkcount += 1
else:
win.blit(char, (x,y))
pygame.display.update()
while run:
clock.tick(27)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run=False
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and x> vel:
x -= vel
left = True
right = False
elif keys[pygame.K_RIGHT] and x< 500-width-vel:
x += vel
left = False
right = True
else:
right = False
left = False
walkcount = 0
if not (iJ):
if keys[pygame.K_SPACE]:
iJ = True
right = False
left = False
walkcount = 0
else:
if jC >= -10:
neg = 1
if jC < 0:
neg = -1
y-=(jC**2) *0.5 *neg
jC -= 1
else:
iJ = False
jC=10
redrawGameWindow()
pygame.quit()
我正在MacOS上运行。我使用的是Python 2还是3,这有关系吗? 任何帮助将不胜感激!
答案 0 :(得分:0)
您忘记在上一行290处加上一个括号。
这种语法错误与Python版本或操作系统无关。
您可以使用IDE(例如PyCharm,EMACS)或静态分析器(例如pycheck)轻松发现它。
答案 1 :(得分:0)
这是丢失的')'
请先检查以下行:
print(': Starting Active Trader with preferred stock {}...'.format([preferredStock[0]])
stock_list.remove(preferredStock[0])
缺少用于打印的右括号。