Hello = type('Hello', (object), dict(hello=fn))
如果第二个参数继承了object就报错: TypeError: type.__new__() argument 2 must be tuple, not type。
不加就能正常运行:Hello = type('Hello', (), dict(hello=fn)) ?
你再仔细对比示例。
第二个少了一个‘,’号
应该是Hello = type('Hello', (object,), dict(hello=fn))
Sign in to make a reply
一把破木吉他
Hello = type('Hello', (object), dict(hello=fn))
如果第二个参数继承了object就报错: TypeError: type.__new__() argument 2 must be tuple, not type。
不加就能正常运行:Hello = type('Hello', (), dict(hello=fn)) ?