【pycharm】设置pycharm python文件模板

1. 模板的相关参数

    官方链接:https://www.jetbrains.com/help/pycharm/file-template-variables.html#predefined_template_variables

    

Variable

Description

${DATE}

Current system date

${DAY}

Current day of the month

${DIR_PATH}

Path to the directory of the new file (relative to the project root)

${DS}

Dollar sign $. This variable is used to escape the dollar character, so that it is not treated as a prefix of a template variable.

${FILE_NAME}

Name of the new file

${HOUR}

Current hour

${MINUTE}

Current minute

${SECOND}

Current second

${MONTH}

Current month

${MONTH_NAME_FULL}

Full name of the current month (January, February, and so on)

${MONTH_NAME_SHORT}

First three letters of the current month name (Jan, Feb, and so on)

${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

 

2. 设置自己的魔板

复制代码
#!/usr/bin/env python  
# -*- coding:utf-8 -*-  
"""
@author: your name eg: Zhang San
@file: ${NAME}.py
@time: ${DATE} ${TIME}
@contact:  your email
@desc: "this is a template for pycharm, please setting for python script."
"""

复制代码

打开 File > settings

 

 找到模板设置的界面 Editor > File and Code Templates

 

 复制到 python script

 

 3. 使用模板创建文件

  然后直接创建文件即可

 

posted @   代码诠释的世界  阅读(340)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示