In the process of using pycharm, it is more convenient to use templates to quickly fill in the shebang line of each new file and some personal information about the code writer.
Methods as below:
1. Open pycharm and select File-Settings
2.选择Editor--Color&Style--File and Templates--Python-Script
3. Edit content
(a)shebang行
#!/usr/bin/python3
(b) Predefined variables are to be expanded to corresponding values in the format ${<variable_name>}.
The available predefined file template variables are:
${PROJECT_NAME} - The name of the current project.
${NAME} - The name of the new file specified in the New File dialog during file creation.
${USER} - The login name of the current user.
${DATE} - The current system date.
${TIME} - Current system time.
${YEAR} - This year.
${MONTH} - The current month.
${DAY} - The day of the month.
${HOUR} - The current hour.
${MINUTE} - the current minute.
${PRODUCT_NAME} - The name of the IDE where the file will be created.
${MONTH_NAME_SHORT} - The first 3 letters of the month name. Example: January, February, etc.
${MONTH_NAME_FULL} - The full name of the month. Example: January, February, etc.
example
##!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : ${DATE} ${TIME} # @Author : Mr Han # @Email : [email protected] # @File : ${NAME}.py # @Software: ${PRODUCT_NAME}
The result is as follows: