Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Automatically add file header, time, date and other information in PyCharm

Shulou Source: shulou.com Published: 2022-06-03 04:36:48 11月25日 Update

When you install PyCharm for the first time, you will find that there is no information in the header when you create a new .py file, so it is convenient to use templates.

The methods are as follows:

Open PyCharm and select File--Settings

Select Editor---Code Style-- File and Code Templates---Python Script in turn

Edit content

You can add the corresponding information as needed

#! / usr/bin/python3

The available predefined file template variables are:

${PROJECT_NAME}-name of the current project.

${NAME}-the name of the new file specified in the New File dialog box during file creation.

${USER}-the login name of the current user.

${DATE}-the current system date.

${TIME}-current system time.

${YEAR}-this year.

${MONTH}-current month.

${DAY}-the day of the month.

${HOUR}-current hour.

${MINUTE}-current minute.

${PRODUCT_NAME}-the name of the IDE in which the file will be created.

${MONTH_NAME_SHORT}-the first three letters of the month name. Example: January, February, etc.

${MONTH_NAME_FULL}-the full name of the month. Example: January, February, etc.

For example:

The display is as follows:

Tags: File name information template example system selection date time middle finger full name content preceding item variable letter dialog box hour method month user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei MySQL Shulou Information Xiaomi