pycharm自動生成檔案註釋和函式註釋
阿新 • • 發佈:2021-07-21
1. 檔案註釋
File -> settings -> Editor -> File and Code Templates -> Python Script
pycharm提供了一個在新建檔案自動生成檔案頭註釋的功能,可以實現自動生成執行環境,作者、日期等必要資訊,使用比較方便,配置十分簡單。
按照1-5的路徑選項即可。在5中填寫想要的註釋。
我的模板:
# -*- encoding: utf-8 -*- ''' @File : ${NAME}.py @Contact : [email protected] @License : (C)Copyright 2018-2021 @Modify Time @Author @Version @Desciption ------------ ------- -------- ----------- ${DATE} ${TIME} Emac.li 1.0 None '''
2. 函式註釋
自動生成函式註釋,包括引數和返回值。
使用方法,函式定義時,直接輸入三個雙引號後回車,例如:
def a(b,c):
另起一行,輸入三個引號,後回車
def a(b,c): """
結果:
def a(b,c): """ :param b: :param c: :return: """