Python的语法规范有哪些具体要求?
- 内容介绍
- 文章标签
- 相关推荐
本文共计401个文字,预计阅读时间需要2分钟。
在Python和Shell中输入`import this`可以查看Python的禅意,它由Tim Peters编写,内容如下:
简洁胜于冗余。明确胜于隐晦。简单胜于复杂。复杂胜于混乱。平面胜于堆叠。
在python shell 中输入 import this
可以看到python之禅
The Zen of Python, by Tim PetersBeautiful 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.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
官网中的PEP8标准
详细的预防规范
官网路径:Documentation——Developer’s Guide——PEP 8
PEP 8 -- Style Guide for Python Code
pycharm配置autopep8
配置后,自动格式化代码
安装 autopep8
cmd窗口输入:pip install autopep8
在Pycharm中安装autopep8配置
配置项目
- Name:Autopep8(可以随便取)
- Tools settings
Programs:autopep8
Arguments:--in-place --aggressive --aggressive \(FilePath\)
Working directory:\(ProjectFileDir\)
点击Output Files→添加,在对话框中的:Regular expression to match output中输入:\(FILE_PATH\):\(LINE\):\(COLUMN\):.*
本文共计401个文字,预计阅读时间需要2分钟。
在Python和Shell中输入`import this`可以查看Python的禅意,它由Tim Peters编写,内容如下:
简洁胜于冗余。明确胜于隐晦。简单胜于复杂。复杂胜于混乱。平面胜于堆叠。
在python shell 中输入 import this
可以看到python之禅
The Zen of Python, by Tim PetersBeautiful 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.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
官网中的PEP8标准
详细的预防规范
官网路径:Documentation——Developer’s Guide——PEP 8
PEP 8 -- Style Guide for Python Code
pycharm配置autopep8
配置后,自动格式化代码
安装 autopep8
cmd窗口输入:pip install autopep8
在Pycharm中安装autopep8配置
配置项目
- Name:Autopep8(可以随便取)
- Tools settings
Programs:autopep8
Arguments:--in-place --aggressive --aggressive \(FilePath\)
Working directory:\(ProjectFileDir\)
点击Output Files→添加,在对话框中的:Regular expression to match output中输入:\(FILE_PATH\):\(LINE\):\(COLUMN\):.*

