PyCharm provides file and code template functions. You can use this template to quickly create new codes or files. For example, when you create a new html file in PyCharm, the new file is not empty, but will automatically fill in some basic necessary content, like this:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Title</title></head><body></body></html>
The template content that comes with the system may not be empty. If it is not what you want, you can modify and add personalized content. For example, if I create a new Python file named main.py, the content will be automatically filled in:
# -*- coding: utf-8 -*-""" ------------------------------------------------- File Name: main.py Description : Author : JHao date: 2017/4/1 ------------------------------------------------- Change Activity: 2017/4/1: ------------------------------------------------- """__author__ = 'JHao'
File Name is the file name, Author is the login system The user name, the date is the current system date. Doesn’t it feel much better than the default blank file? The specific modification steps are: [File] → [Settings] As shown in the figure, find [File and Code Templates] in [Editor] and select what you want You can edit the file type you set.
My template is like this:
# -*- coding: utf-8 -*-""" ------------------------------------------------- File Name: ${NAME} Description : Author : ${USER} date: ${DATE} ------------------------------------------------- Change Activity: ${DATE}: ------------------------------------------------- """__author__ = '${USER}'
Attached are the template variables:
${PROJECT_NAME} - 当前Project名称; ${NAME} - 在创建文件的对话框中指定的文件名; ${USER} - 当前用户名; ${DATE} - 当前系统日期; ${TIME} - 当前系统时间; ${YEAR} - 年; ${MONTH} - 月; ${DAY} - 日; ${HOUR} - 小时; ${MINUTE} - 分钟; ${PRODUCT_NAME} - 创建文件的IDE名称; ${MONTH_NAME_SHORT} - 英文月份缩写, 如: Jan, Feb, etc; ${MONTH_NAME_FULL} - 英文月份全称, 如: January, February, etc;
The above is the detailed content of Detailed explanation of PyCharm custom files and code template examples. For more information, please follow other related articles on the PHP Chinese website!