??
Comments
1, comments
1.1, block comments
"#" ?? ?? ??? ???, ??? ? ?? ?????. ("#" ??? ?????. )
# 塊注釋 # 塊注釋 # # 塊注釋 # 塊注釋
1.2. ?? ??
? ?? ? ? ???? ????? ???. ?? ?? ??? ???? ??? ?????.
??? ?? ???? ?? ????. ??? ??(?? ? ??? ??) ??? ??? ???
? ??? ?? ??? ?? ?? ??? ???? ? ??? ?? ???? ??? ? ????# 正確的寫法 x = x + 1 # 邊框加粗一個(gè)像素 # 不推薦的寫法(無意義的注釋) x = x + 1 # x加1
2. ?? ??(Docstring)
????? Docstring? ????? ?? ??? ?????. ??, ?? ? ???? ??? Python?? ??? __doc__ ??? ?? ??? ?? ? ??? ??? ? IDE??? Docstring? ???? ?? ????? ??? ? ????.
?? ??? """? ???? ???? ? ?? ?? ???? ????. ?? ?? ?? ?? ??? ?? ??? ???. ??? Google? ???? ???? ????app = create_app(name, options) # ===================================== # 請勿在此處添加 get post等app路由行為 !!! # ===================================== if __name__ == '__main__': app.run()?? ?? ?????? ???? ???. ?? ???? ???? ??? ??? ????, ?? ?? ??? ?? ? ?? ?????.
# -*- coding: utf-8 -*- """Example docstrings. This module demonstrates documentation as specified by the `Google Python Style Guide`_. Docstrings may extend over multiple lines. Sections are created with a section header and a colon followed by a block of indented text. Example: Examples can be given using either the ``Example`` or ``Examples`` sections. Sections support any reStructuredText formatting, including literal blocks:: $ python example_google.py Section breaks are created by resuming unindented text. Section breaks are also implicitly created anytime a new section starts. """?? ?? ??, ?? ? ?? ?? ??? ??? ?? numpy ??? ?????.
# 不推薦的寫法(不要寫函數(shù)原型等廢話) def function(a, b): """function(a, b) -> list""" ... ... # 正確的寫法 def function(a, b): """計(jì)算并返回a到b范圍內(nèi)數(shù)據(jù)的平均值""" ... ...?? ?? ???? ??? ???? ?? ???? ??? ?? ????? ??? ??? ?? ??? ????? ?? ???? ??? ??? ? ????. ?? ???? ???????, ?? ???, ?? ?? ???. ?? ??? ??? ? ?? ??? ??? ?? ?? ??? ???? ???