pygame.rect.Rect() 和 pygame.Rect() 之间的根本区别是什么?

What is the fundamental difference between pygame.rect.Rect() and pygame.Rect()?

我尝试了这个和那个,很惊讶这两种方法都有效并且给出了相同的结果。但是拼写的差异一定是有道理的吧?

rect = pg.rect.Rect(x, y, width, height)
rect = pg.Rect(x, y, width, height)

def draw():
        draw.rect(screen, color, rect)

在这种情况下,您可以轻松地深入了解 lib 内部结构并自行调查。其实pygame/__init__.py里有一行from pygame.rect import Rect。没有其他重新分配,因此没有区别。只是为了方便起见而已。