初次安裝使用PyCharm,在新建.py文件時會發現文件頭並沒有什么信息,因此,使用模板會比較方便。
方法如下:
1.打開PyCharm,選擇File--Settings
2.依次選擇Editor---Code Style-- File and Code Templates---Python Script
3.編輯內容
可以根據需要添加相應的信息
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
ScriptName: ${NAME}
Project: ${PROJECT_NAME}
Author: MeiMeiLong.
Create Date: ${YEAR}-${MONTH}-${DAY} ${HOUR}:${MINUTE}:${SECOND}
Description:
"""
__author__ = 'longlong'</code>
#!/usr/bin/env bash
#ScriptName: ${NAME}
#Project: ${PROJECT_NAME}
#Author: MeiMeiLong.
#Create Date: ${YEAR}-${MONTH}-${DAY} ${HOUR}:${MINUTE}:${SECOND}
#Description:
可用的預定義文件模板變量為:
###Chinese Ver.
$ {PROJECT_NAME} - 當前項目的名稱。
$ {NAME} - 在文件創建過程中在“新建文件”對話框中指定的新文件的名稱。
$ {USER} - 當前用戶的登錄名。
$ {DATE} - 當前的系統日期。
$ {TIME} - 當前系統時間。
$ {YEAR} - 今年。
$ {MONTH} - 當月。
$ {DAY} - 當月的當天。
$ {HOUR} - 目前的小時。
$ {MINUTE} - 當前分鍾。
$ {PRODUCT_NAME} - 將在其中創建文件的IDE的名稱。
$ {MONTH_NAME_SHORT} - 月份名稱的前3個字母。 示例:1月,2月等
$ {MONTH_NAME_FULL} - 一個月的全名。 示例:1月,2月等
###English Ver.
${PROJECT_NAME} - the name of the current project.
${NAME} - the name of the new file which you specify in the New File dialog box during the file creation.
${USER} - the login name of the current user.
${DATE} - the current system date.
${TIME} - the current system time.
${YEAR} - the current year.
${MONTH} - the current month.
${DAY} - the current day of the month.
${HOUR} - the current hour.
${MINUTE} - the current minute.
${PRODUCT_NAME} - the name of the IDE in which the file will be created.
${MONTH_NAME_SHORT} - the first 3 letters of the month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL} - full name of a month.