Python行为异常?即使在定义布尔值时也是如此?
这只是python的初学者,所以我的代码不是那么可读,也不干净。但是,我想知道为什么我会出错Python行为异常?即使在定义布尔值时也是如此?,python,pygame,boolean,Python,Pygame,Boolean,这只是python的初学者,所以我的代码不是那么可读,也不干净。但是,我想知道为什么我会出错 import pygame pygame.init() pygame.font.init() # Colors yellow = (250, 250, 100) brown = (50, 0, 15) pink = (224, 7, 184) white = (250, 250, 250) # Vairables screen = pygame.display.set_mode() heading_
import pygame
pygame.init()
pygame.font.init()
# Colors
yellow = (250, 250, 100)
brown = (50, 0, 15)
pink = (224, 7, 184)
white = (250, 250, 250)
# Vairables
screen = pygame.display.set_mode()
heading_text = pygame.font.SysFont("Comic Sans MS", 42)
heading_text_surface = heading_text.render('Time Table', True, (0, 0, 0))
today_text = pygame.font.SysFont("Comic Sans MS", 42)
today_text_surface = today_text.render('Today', True, (250, 250, 250))
tommorow_text = pygame.font.SysFont("Comic Sans MS", 42)
tommorow_text_surface = tommorow_text.render('Tommorow', True, (250, 250, 250))
all_days_text = pygame.font.SysFont("Comic Sans MS", 42)
all_days_text_surface = all_days_text.render('All Days', True, (250, 250, 250))
maths_text1 = pygame.font.SysFont("Comic Sans MS", 42)
maths_text1_surface = maths_text1.render('Maths', True, (255, 255, 255))
zero_hour = pygame.font.SysFont("Comic Sans MS", 42)
zero_hour_surface = zero_hour.render('Zero Hour', True, (0, 153, 255))
time_120to150 = pygame.font.SysFont("Comic Sans MS", 36)
time_120to150_surface = time_120to150.render('1:20PM to 1:50PM', True, (('Zero Hour', True, (0, 153, 255))))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill(yellow)
pygame.draw.rect(screen, brown, (52, 75, 1800, 75))
screen.blit(heading_text_surface, (800, 10))
screen.blit(today_text_surface, (95, 85))
screen.blit(tommorow_text_surface, (295, 85))
screen.blit(all_days_text_surface, (570, 85))
pygame.draw.rect(screen, pink, (52, 250, 700, 130))
pygame.draw.rect(screen, pink, (52, 475, 700, 130))
pygame.draw.rect(screen, pink, (52, 700, 700, 130))
pygame.draw.rect(screen, pink, (52, 925, 700, 130))
screen.blit(maths_text1_surface, (73, 264))
screen.blit(time_120to150_surface, (90, 264))
pygame.display.flip()
错误:
再说一次,我只是个初学者,所以我在这方面没有经验。
为什么会出现语法错误,但running=True是正确的。请帮我解决这个问题。试着在
running=True
之前将行更改为:
time_120to150_surface = time_120to150.render('1:20PM to 1:50PM', True, ('Zero Hour', True, (0, 153, 255)))
我删除了一组额外的括号。该代码不会产生该错误。在
running=True
之前的行中有一个错误。这似乎是一个复制/粘贴问题。