PyCharm头部模板和函数注释自动生成

PyCharm头部模板和函数注释自动生成

oyxy2019 251 2023-11-16

一、设置新建文件的头模板

设置——编辑器——文件和代码模板——“Python Script”——添加模板

##########################################################
# @Author: oyxy2019
# @Date: ${DATE}
# @Description: xxxx
##########################################################

二、函数自动注释

设置——工具——Python集成工具——Docstring格式

可以改为Google风格等,在函数定义下面一行敲三双引号就能自动生成函数注释如下

def func(path, field_storage, temporary):
    '''基本描述

    Args:
        path (str): The path of the file to wrap
        field_storage (FileStorage): The :class:`FileStorage` instance to wrap
        temporary (bool): Whether or not to delete the file when the File instance is destructed

    Returns:
        BufferedFileStorage: A buffered writable file descriptor
    '''
    pass