Use Pycharm to set python script file header

1. Pycharm setting address

Open pycharm, click file-->settings-->editor-->file and code templates-->select Python Script

2. Template declaration setting reference

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : ${DATE} ${HOUR}:${MINUTE}
# @Author  : 作者名
# @Site    : ${SITE}
# @File    : ${NAME}.py
# @Project : ${PROJECT_NAME}
# @Software: ${PRODUCT_NAME}

2.1. The effect of the above settings to create a new file

2.2. Add required variable content

The required declaration content can be further added as required. . . Refer to the above form to add
# @email: [email protected]

It is generally not recommended to use too much information:
Recommended: declare character encoding, time, author, file name. All four are fine. (you can decide according to your own needs)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : ${DATE} ${HOUR}:${MINUTE}
# @Author : author name
# @File : ${ NAME}.py

3. Template predefined variable reference

${DATE} Current system date
${DAY} Current day of month
${DS} dollar sign $. This variable is used to escape dollar characters so that they are not considered as prefixes to template variables.
${FILE_NAME} The name of the new file.
${HOUR} current time
${MINUTE} current minute
${MONTH} this month
${MONTH_NAME_FULL} full name of the month (January, February, etc.)
${MONTH_NAME_SHORT} first three letters of the current month name (Jan, Feb, etc.) )
${NAME} name of the new entity (file, class, interface, etc.)
${PRODUCT_NAME} name of the IDE (eg PyCharm)
${PROJECT_NAME} current project name
${TIME} current system time
${USER} current user's login name
${YEAR} this year

Guess you like

Origin blog.csdn.net/weixin_37600187/article/details/128331364