【pycharm】设置pycharm python文件模板


1. 模板的相关参数

    官方链接:https://www.jetbrains.com/help/pycharm/file-template-variables.html#predefined_template_variables

    

Variable

Description

${DATE}

Current system date

${DAY}

Current day of the month

${DIR_PATH}

Path to the directory of the new file (relative to the project root)

${DS}

Dollar sign $. This variable is used to escape the dollar character, so that it is not treated as a prefix of a template variable.

${FILE_NAME}

Name of the new file

${HOUR}

Current hour

${MINUTE}

Current minute

${SECOND}

Current second

${MONTH}

Current month

${MONTH_NAME_FULL}

Full name of the current month (January, February, and so on)

${MONTH_NAME_SHORT}

First three letters of the current month name (Jan, Feb, and so on)

${NAME}

Name of the new entity (file, class, interface, and so on)

${PRODUCT_NAME}

Name of the IDE (for example, PyCharm)

${PROJECT_NAME}

Name of the current project

${TIME}

Current system time

${USER}

Login name of the current user

${YEAR}

Current year

2. 设置自己的魔板

#!/usr/bin/env python  
# -*- coding:utf-8 -*-  
"""
@author: your name eg: Zhang San
@file: ${NAME}.py
@time: ${DATE} ${TIME}
@contact:  your email
@desc: "this is a template for pycharm, please setting for python script."
"""

打开 File > settings

 找到模板设置的界面 Editor > File and Code Templates

 复制到 python script

 3. 使用模板创建文件

  然后直接创建文件即可