python - 注釋說明
歸類三種注釋風格:
- 大段的自定義塊狀注釋
""" #========================================= # FileName: upgrade_idirector.py # Desc: # Author: Blithe Gu # Email: bngu@wisu.com.cn # HomePage: wwww.wisu.com.cn # Version: 0.0.1 # LastChange: 2017-11-06 14:28:14 # History: #========================================= """
- 大段的函數語句塊注釋
#### 函數型注釋 ############################### # 刪除舊的idirector # def remove_old_idirector_path(self): # if self.idirector_path == self.new_qm_path: # pass # elif self.idirector_path == self.old_qm_path: # cmd = "rm -rf {old_path}".format(old_path=self.old_qm_path) # stdout, stderr = self.local_cmd(cmd) # print fmt(self.YELLOW, "[START]:remove idirector directory", "ok", "") #### 語句型注釋 ############################### ############################# CHECK MYSQL #################################################### mysql_variables = func.get_mysql_variables(cur) …… # 其他內容 ############################# GET VARIABLES ################################################### version = func.get_item(mysql_variables,'version') key_buffer_size = func.get_item(mysql_variables,'key_buffer_size') …… # 其他內容 ############################# GET INNODB INFO ################################################## #innodb variables innodb_version = func.get_item(mysql_variables,'innodb_version') innodb_buffer_pool_instances = func.get_item(mysql_variables,'innodb_buffer_pool_instances') innodb_buffer_pool_size = func.get_item(mysql_variables,'innodb_buffer_pool_size') …… # 其他內容
- 單條語句注釋
#### 小段注釋內容 用于說明一部分代碼內容或者單條語句內容 ###### # check sga_param sga_param = oracle.get_sga_param(oracle_pool) if sga_param: …… #其他內容 # check sga_usage sga_usage = oracle.get_sga_usage(oracle_pool) if sga_usage: …… #其他內容 #### 對函數進行注釋 寫在函數之前 #################### # check_os_rsa 為檢查是否存在建立安全關系的證書 def check_os_rsa(self): …… #其他內容 # check_os_hostname 為檢查hostname的方法 def check_os_hostname(self): …… #其他內容

浙公網安備 33010602011771號