美文网首页
[Intelli J IDE] PyCharm应用技巧1

[Intelli J IDE] PyCharm应用技巧1

作者: 4b6faa1b17a3 | 来源:发表于2017-07-05 08:00 被阅读0次

    前言

    追求效率和便利应该是我们永久不变的信仰。今天就为大家介绍一个PyCharm的设置技巧,可以减少我们在新建python文件时的一些繁琐的设置。

    应用场景

    新建文件时自动设置文件头部模板。

    操作步骤

    File->settings->Editor->File and Code Templates然后在右侧选择"Files",找到“Python Script”

    # encoding: utf-8
    """
    @author: Micheal 
    @contact: salc3k@qq.com
    @site: lantingtalk.com
    @file: ${NAME}.py
    @time: ${DATE} ${TIME}
    """
    
    
    可使用的预置文件模板变量有:
    ${PROJECT_NAME}
     - the name of the current project.
    ${NAME}
     - the name of the new file which you specify in the New Filedialog 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. Example: January, February, etc.
    
    自定义变量:
    
    #set( $SITE = "http://lantingtalk.com" )
    
    """
    @version: python2.7
    @author: ‘$USER‘
    @license: Apache Licence 
    @contact: 369023466@qq.com
    @site: ${SITE}
    @software: ${PRODUCT_NAME}
    @file: ${NAME}.py
    @time: ${DATE} ${TIME}
    """
    
    Custom variables. Their names can be defined right in the template through the #set
     directive or will be defined during the file creation.
    
    To have the dollar character ($
    ) in a variable rendered "as is", use the${DS}
     variable instead. This variable evaluates to a plain dollar character ($
    ).
    Apply the changes and close the dialog box. 
    

    相关文章

      网友评论

          本文标题:[Intelli J IDE] PyCharm应用技巧1

          本文链接:https://www.haomeiwen.com/subject/epufhxtx.html