list123342 发表于 2018-8-15 09:01:33

python常用模块初始

查找python默认全局环境变量位置:  
import sys
  
#导入sys模块
  
print (sys.path)
  
#打印python的所有目录,python放模块的目录是/usr/lib/python2.7/dist-packages
  
#把文件上传到该目录下,名字tab.py
  
import tab
  
#os.就可以tab补全了;注意不能加.py
  
#tab模块要自己写;
  
#每一个脚本都可以是一个模块;
  

  
具体TAB模块内容:
  
#!/bin/bash/env python
  
#_*_ coding:utf-8 _*_
  

  
# python startup file
  
import sys
  
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
页: [1]
查看完整版本: python常用模块初始