Home > other >  Python from entry to practice in the book, reoccupy pycharm create a pygame window, appear error, a
Python from entry to practice in the book, reoccupy pycharm create a pygame window, appear error, a

Time:09-20

The original code: the following
The import sys
The import pygame
Def run_game () :
Pygame. The init ()
Screen=pygame. Display. Set_mode ((1200800))
Pygame. Display. Set_caption (' Alien night ')
While True:
For the event in pygame. Event. The get () :
If the event. The type==pygame. QUIT:
Sys. The exit ()
Pygame. Display. Flip ()
Run_game ()

CodePudding user response:

The answer of torture, a day or two

CodePudding user response:

Error information display module pygame didn't QUIT this attribute
The QUIT this attribute is pygame. Locals
So you want to import like this:
The from pygame. Locals import *
Then

While True:
For the event in pygame. Event. The get () :
If the event type==the QUIT:

The exit ()

CodePudding user response:

I find a way to solve, I have encountered this problem...
  • Related