當(dāng)你使用Pycharm新建文件時(shí),它會(huì)生成一個(gè)空白文件⌒至眩可能你需要讓它填充一些共用的代碼,比如文件頭阳藻、類的聲明語句等
Pycharm的文件模版就是解決這個(gè)問題的,下面以python代碼為例
1 打開設(shè)置(Preference)->編輯(Editor)->文件代碼模版(File and Code Templates)->點(diǎn)擊“+”
2 如圖分別輸入模版名晰奖,后綴,以及文本內(nèi)容
3 保存
4 試試文件模版是否好用
在項(xiàng)目右鍵然后選擇新建文件即可看到文件模版
5 輸入文件名后確認(rèn)腥泥,新文件出現(xiàn)了
6 補(bǔ)充文件模版示例代碼與可用的變量
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@desc:
@author: ${USER}
@software: PyCharm on ${DATE}
"""
可用變量
Variable
Description
${DATE}
Current system date
${DAY}
Current day of the month
${END}
Caret position after you finish editing the variables
${HOUR}
Current hour
${MINUTE}
Current minute
${MONTH}
Current month
${MONTH_NAME_FULL}
Full name of the current 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, and so on)
${PRODUCT_NAME}
Name of the IDE (for example, PyCharm)
${PROJECT_NAME}
Name of the current project
${TIME}
Current system time
${USER}
Login name of the current user
${YEAR}
Current year