This code is used to display a picture
1 #-*-coding:utf-8-*-2 ImportPygame#Import Pygame Library3 fromSysImportExit#borrowing the exit function from the SYS module to exit the program4Pygame.init ()#Initialize Pygame5 6Screen = Pygame.display.set_mode ((600,170), 0,32)7 #Create a window, the first parameter is Ganso, represents the resolution, the second is the flag bit, the default 0, if it is fullscreen, it is full screen, the third is the color depth8Pygame.display.set_caption ("Hello world!")#Set Window caption9Background = Pygame.image.load ('A.png'). CONVERT ()#load and convert imagesTen One whileTrue: A forEventinchpygame.event.get (): - ifEvent.type = =Pygame. QUIT: - pygame.quit () the exit () -Screen.blit (background, (0,0))#draw the background image, the first parameter is the Surface object, the second argument is the upper left corner of the sitting - -Pygame.display.update ()#Refresh Screen
Python Games first lesson