zoukankan      html  css  js  c++  java
  • python的使用环境总结

    python在linux上运行,使用的是vim,每次都是敲四个空格进行缩进,真尼玛的蛋疼,书本果然是个好东西,从而根据书本python高级编程中的设置配置而来:

    1、进行自动补全的脚本

    [root@python ~]# cat .pythonstartup 
    #python startup file
    import readline
    import rlcompleter
    import atexit
    import os
    #tab completion
    readline.parse_and_bind('tab:complete')
    #history file
    histfile = os.path.join(os.environ['HOME'],'.pythonhistory')
    try:
        readline.read_history_file(histfile)
    except IOError:
        pass
    atexit.register(readline.write_history_file,histfile)
    del os,histfile,readline,rlcompleter
    主要是用来进行命令自动补全,和linux中的是一样一样的

    写好这个之后,必须配置环境变量,在bash_profile中新增一项,如果没有这个文件在RHEL系列中,那么就是别的家目录文件中:

    [root@python ~]# cat .bash_profile |grep PYTHONS
    export PYTHONSTARTUP='.pythonstartup'
    写好上面的两部之后,记得重新登录,或者直接读取环境变量,从而可以使用上面的设置:
    [root@python ~]# source .bash_profile 


    2、自动缩进

    用来进行自动缩进,主要就是因为。。。需要打太多的空格来进行缩进,从而使用到的是vim的配置文件.vimrc

    具体内容设置如下:

    [root@python ~]# cat .vimrc 
    set expandtab
    set textwidth=0
    set tabstop=4
    set softtabstop=4
    set shiftwidth=4
    set autoindent
    set smartindent
    set backspace=indent,eol,start
    set incsearch
    set ignorecase
    set ruler
    set wildmenu
    set commentstring= # %s
    set foldlevel=0
    set clipboard+=unnamed
    syntax enable
    syntax on
    基本意思就是缩进的时候,使用的tab是四个空格,进行自动和只能缩进,增强搜索,并且忽略大小写,语法高亮


    有了这个,再也不需要打无数个空格而烦恼,也不用说几个空格就是规范了。



  • 相关阅读:
    sql server 获取本月的始末时间
    超时时间已到
    sql server定时自动备份
    创建连接服务器
    date制作电子时钟
    C#继承(三)
    C# Split分割
    Dom动态添加属性
    date制作电子时钟(二)
    全局遮罩 shade
  • 原文地址:https://www.cnblogs.com/kellyseeme/p/5525044.html
Copyright © 2011-2022 走看看