Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果是这样,你会怎么做。
def methodname(self, blah, blah) ^如何在其中放置一个函数。
是的,你只是坚持一个def里面。你甚至可以在函数和方法中嵌套整个类:
def
class Foo(object): def method(self, bar): def inner(magic): class Madness(object): def __init__(inself, foo): inself.foo = foo return Madness(magic) return inner(bar)