- 論壇徽章:
- 0
|
初學(xué)(自學(xué))Python,照著寫了下面代碼但是運(yùn)行的時(shí)候提示:
line 18, in <module>
colour[2] += increment
ValueError: invalid color argument
請(qǐng)教為何會(huì)出這個(gè)錯(cuò)誤,如何解決這個(gè)錯(cuò)誤(我的是Python 3.6.4在win32位)
源代碼如下:
import pygame
pygame.init()
width = 400
height = 300
windowSize = (width , height)
screen = pygame.display.set_mode(windowSize)
colour = pygame.color.Color('#646400')
row = 0
done = False
while not done:
increment = 255/100
while row <= height:
pygame.draw.rect(screen,colour,(0, row, width, row + increment))
pygame.display.flip()
if colour[2] + increment < 255:
colour[2] += increment
row += increment
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
pygame.quit()
|
|