1.按照下面路徑以此打開
1
|
file →→settings→→editor→→ file and code templates |
右側(cè)找到python script,如下圖
2.設(shè)置相關(guān)代碼
如下
1
2
3
4
5
6
7
|
##!/usr/bin/python3 # -*- coding: utf-8 -*- # @time : ${date} ${time} # @author : 未來戰(zhàn)士biubiu!! # @filename: ${name}.py # @software: ${product_name} # @blog :http://blog.csdn.net/u010105243/article/ |
設(shè)定的規(guī)則說明如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
(a)shebang行 #!/usr/bin/python3 (b)預(yù)定義的變量要擴(kuò)展為格式為$ {<variable_name>}的相應(yīng)值。 可用的預(yù)定義文件模板變量為: $ {project_name} - 當(dāng)前項目的名稱。 $ {name} - 在文件創(chuàng)建過程中在“新建文件”對話框中指定的新文件的名稱。 $ {user} - 當(dāng)前用戶的登錄名。 $ {date} - 當(dāng)前的系統(tǒng)日期。 $ {time} - 當(dāng)前系統(tǒng)時間。 $ {year} - 今年。 $ {month} - 當(dāng)月。 $ {day} - 當(dāng)月的當(dāng)天。 $ {hour} - 目前的小時。 $ {minute} - 當(dāng)前分鐘。 $ {product_name} - 將在其中創(chuàng)建文件的ide的名稱。 $ {month_name_short} - 月份名稱的前 3 個字母。 示例: 1 月, 2 月等 $ {month_name_full} - 一個月的全名。 示例: 1 月, 2 月等 |
以上這篇在pycharm中自動添加時間日期作者等信息的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://blog.csdn.net/u010105243/article/details/76154251