Files
freeCodeCamp/guide/chinese/python/python-coding-standards/index.md
Randell Dawson 0a1eeea424 fix(guide) Replace invalid prism code block names (#35961)
* 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
2019-05-15 19:08:19 +02:00

1.2 KiB
Raw Blame History

title, localeTitle
title localeTitle
Coding standards 编码标准

大纲

  • 为什么编码标准?
  • PEP 8简介
  • 命令

为什么编码标准?

全球python社区正在快速增长几乎每个人都使用python。这是代码和统一标准的可读性很重要的地方。地球上的任何人都应该能够阅读您的代码并了解它的作用。理解其他代码有很多方面例如关于函数功能的评论逻辑上在模块和函数之间划分任务良好的变量名称等。

PEP 8简介

我们喜欢坚持惯例。 python用户社区已经提出了一套标准现在这些标准被视为惯例。您编写的任何行业级代码都通过PEP 8检查程序运行。因此开始为您的类和函数编写文档字符串并使用approrpiate下划线以小写字母命名变量是一种很好的做法。在开始编码之前看看这些标准可能是值得的。

这是详尽的链接

命令

这是你如何检查你的python代码是否符合他的标准。

:~$ pip install pep8 
 :~$ pep8 --first myCode.py 

这将提供违反标准的所有行,以及修复的简短描述。