有人可以解释这个奇怪的Pygame导入约定吗? [英] Can someone please explain this weird Pygame importing convention?
本文介绍了有人可以解释这个奇怪的Pygame导入约定吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到人们通常会像这样导入Pygame:
I see that people usually import Pygame like this:
import pygame
from pygame.locals import *
我不明白第二行是什么。如果我们已经导入了整个Pygame,为什么要导入 pygame.locals
? Pygame一旦导入就不会包含它吗?
I don't understand what's the second line for. If we already imported the whole of Pygame, why import pygame.locals
? Doesn't Pygame already include it once it's imported?
推荐答案
import pygame
将pygame模块导入pygame命名空间。
imports the pygame module into the "pygame" namespace.
from pygame.locals import *
复制所有名称pygame.locals到你当前的命名空间。这不是必要的,但可以节省您输入的费用。
copys all names in pygame.locals into your current namespace. This is not neccessary, but saves you typing.
这篇关于有人可以解释这个奇怪的Pygame导入约定吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文