Use 4-space indentation, and no tabs.
#使用4空格缩进,不要使用tab缩进
Wrap lines so that they don’t exceed 79 characters.
拆行确保每行不超过79个字符
Use blank lines to separate functions and classes, and larger blocks of code inside functions.
函数和类之间用空行隔开,包括大块代码段也用空行隔开
When possible, put comments on a line of their own.
注释单独占一行
Use docstrings.
使用文档字符串
Use spaces around operators and after commas, but not directly inside bracketing constructs: a = f(1, 2) + g(3, 4).
操作符两侧和逗号后面留空格,但括号里侧不加空格:a = f(1, 2) + g(3, 4)
Name your classes and functions consistently; the convention is to use CamelCase for classes and lower_case_with_underscores for functions and methods. Always use self as the name for the first method argument (see A First Look at Classes for more on classes and methods).
统一类名和函数名,推荐类名用驼峰命名:SampleClass,函数名用小写和下划线命名:get_page(),尽量用self作为方法的第一个参数
Don’t use fancy encodings if your code is meant to be used in international environments. Plain ASCII works best in any case.
国际化环境中慎用编码,ASCII最佳。(中文环境下,推荐utf-8)