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.
你会如何处理长__repr__字符串?有最佳实践吗?可以说我有以下内容。
__repr__
class Foo(object): def __init__(self, bar): self.bar = bar def __repr__(self): return 'Foo(bar={0!r})'.format(self.bar) foo = Foo(largedict) print repr(foo)
在表示字符串中添加换行符是否有用?
您可能会发现santdard库中的 pprint 很有用。