python的自动补全

新建python_start_up_file文件

# 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:
    
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter

$HOME/.profile文件中写入

export PYTHONSTARTUP=$HOME/.python_start_up_file

小注:

可以使用py3compile来编译文件,然后使用python3+文件名来运行

Python-使用hexo的python脚本

为了简化blog的使用写的python脚本,用来简化自己的操作= =

更新了一下。

最新的代码在coding.net上

#!/usr/bin/env python2
# coding: UTF-8
import sys
import os
# 博客目录
blog_dir = '/home/svitter/svtter.github.io/source/_posts'
def help():
    '''output help information'''
    print '-n: new blog'
    print '-g: Generate and push'
    print '-h: help'
if len(sys.argv) < 2:
    print 'no option'
    help()
else:
    if sys.argv[1].startswith('-'):
        # 改变工作目录
        os.chdir(blog_dir)
        option = sys.argv[1][1:]
        if option == 'n':
            os.system("hexo n " + sys.argv[2])
            os.system("gvim " + sys.argv[2] + ".md")
        elif option == 'g':
            os.system('hexo g')
            os.system('hexo d')
            os.chdir('/home/svitter/svtter.github.io')
            os.system('. update')
        elif option == 'h':
            help()
        elif option == 'dir':
            print blog_dir
        elif option == 'e':
            os.system('gvim ' + blog_dir)
        else:
            print 'no such command.'
    else:
        help()
hexo  python