Python的“最佳格式惯例”用于列表,字典等 [英] Python "best formatting practice" for lists, dictionary, etc
本文介绍了Python的“最佳格式惯例”用于列表,字典等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在查看 Python 文档,以获取有关代码格式化的最佳做法大列表和字典,例如,
I have been looking over the Python documentation for code formatting best practice for large lists and dictionaries, for example,
something = {'foo' : 'bar', 'foo2' : 'bar2', 'foo3' : 'bar3'..... 200 chars wide, etc..}
或
something = {'foo' : 'bar',
'foo2' : 'bar2',
'foo3' : 'bar3',
...
}
或
something = {
'foo' : 'bar',
'foo2' : 'bar2',
'foo3' : 'bar3',
...
}
如何处理列表/字典的深层嵌套?
How do I handle deep nesting of lists/dictionaries?
推荐答案
我的首选方法是:
something = {'foo': 'bar',
'foo2': 'bar2',
'foo3': 'bar3',
...
'fooN': 'barN'}
这篇关于Python的“最佳格式惯例”用于列表,字典等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文