美文网首页
10-Python02

10-Python02

作者: CrUelAnGElPG | 来源:发表于2018-08-07 10:03 被阅读0次

    python官网给出的编程规范

    1.Use 4-space indentation, and no tabs.

    2.Wrap lines so that they don’t exceed 79 characters.

    3.Use blank lines to separate functions and classes, and larger blocks of code inside functions.

    4.When possible, put comments on a line of their own.

    5.Use docstrings.

    6.Use spaces around operators and after commas, but not directly inside bracketing constructs: a = f(1, 2) + g(3, 4).

    7.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).

    8.Don’t use fancy encodings if your code is meant to be used in international environments. Python’s default, UTF-8, or even plain ASCII work best in any case.

    9.Likewise, don’t use non-ASCII characters in identifiers if there is only the slightest chance people speaking a different language will read or maintain the code

    相关文章

      网友评论

          本文标题:10-Python02

          本文链接:https://www.haomeiwen.com/subject/cplovftx.html