* fix: replace sh with shell fix replace terminal with shell fix replace node with js fix replace output with shell fix replace cs with csharp fix replace c++ with cpp fix replace c# with csharp fix replace javasctipt with js fix replace syntax with js fix replace unix with shell fix replace linux with shell fix replace java 8 with java fix replace swift4 with swift fix replace react.js with jsx fix replace javascriot with js fix replace javacsript with js fix replace c++ - with cpp fix: corrected various typos fix: replace Algorithm with nothing fix: replace xaml with xml fix: replace solidity with nothing fix: replace c++ with cpp fix: replace txt with shell fix: replace code with json and css fix: replace console with shell
30 lines
1.2 KiB
Markdown
30 lines
1.2 KiB
Markdown
---
|
||
title: Coding standards
|
||
localeTitle: 编码标准
|
||
---
|
||
### 大纲
|
||
|
||
* 为什么编码标准?
|
||
* PEP 8简介
|
||
* 命令
|
||
|
||
### 为什么编码标准?
|
||
|
||
全球python社区正在快速增长,几乎每个人都使用python。这是代码和统一标准的可读性很重要的地方。地球上的任何人都应该能够阅读您的代码并了解它的作用。理解其他代码有很多方面,例如关于函数功能的评论,逻辑上在模块和函数之间划分任务,良好的变量名称等。
|
||
|
||
### PEP 8简介
|
||
|
||
我们喜欢坚持惯例。 python用户社区已经提出了一套标准,现在这些标准被视为惯例。您编写的任何行业级代码都通过PEP 8检查程序运行。因此,开始为您的类和函数编写文档字符串,并使用approrpiate下划线以小写字母命名变量是一种很好的做法。在开始编码之前,看看这些标准可能是值得的。
|
||
|
||
[这是详尽的链接](https://www.python.org/dev/peps/pep-0008/ "PEP 8标准")
|
||
|
||
### 命令
|
||
|
||
这是你如何检查你的python代码是否符合他的标准。
|
||
|
||
```shell
|
||
:~$ pip install pep8
|
||
:~$ pep8 --first myCode.py
|
||
```
|
||
|
||
这将提供违反标准的所有行,以及修复的简短描述。 |