在pygame.display.set_模式()返回曲面对象。在pygame.display.set_mode initialize a window or screen for display
pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface
所以您是在surface对象上调用方法.fill(),而不是函数set_mode()。在
您可以在pygame的surface documentation中找到表面对象上可用的方法。在
不能用这种方式调用嵌套函数。
要在打印示例中获得所需的结果,可以按以下方式使用类:class F():
def g(self):
print "hi"
导致:
^{pr2}$
这是一个简化的示例,演示display.set_mode().fill()是如何工作的:class Surface():
def fill(self):
print "filling"
class Display():
def set_mode(self):
return Surface()
Display().set_mode().fill()
编辑:
您可以使用嵌套函数,但它的工作方式与使用对象和模块的方式略有不同:def f():
def g():
print "hi"
return g
导致:>>> outerf = f()
>>> outerf()
hi