让Python代码离Pythonic更近一步

如果你也听说过著名的“the zen of python”,如果你和我一样小白到写的代码总是乱七八糟,如果你也想了解一下真正“Pythonic”的代码是什么样子的话,不妨看下去。

pythonic,简单的翻译就是python风格,pythonic code,就是说你写的代码要带有浓厚的python规范和python风格。往规范了说,PEP 8是你写出规范代码不得不读的文章,至于往python风格来说的话让,嗯,让我们先看看“the zen of python”中的几句话:

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.

总结一句话:Pythonic就是以Python的方式写出简洁优美的代码!

作者:Qingyun
                
comments powered by Disqus