Python的互动式cmd可根据起动文档来配备。
当Python启动,会搜索系统变量PYTHONSTARTUP,而且实行该自变量中所特定文档里的编程代码。该特定文件目录及其详细地址能够是随便的。按Tab键的时候会全自动补齐內容和指令历史时间。这对cmd的合理提高,而这种专用工具则是根据readline控制模块完成的(这必须readline程序库輔助完成)。
这里为大伙儿举一个简易的起动脚本文件事例,它为pythoncmd加上了功能键全自动补齐內容和历史时间指令作用。[python@python ~]$ cat .pythonstartupimport readlineimport rlcompleterimport atexitimport os#tab completionreadline.parse_and_bind('tab: complete')#history filehistfile = os.path.join(os.environ['HOME'], '.pythonhistory')try: readline.read_history_file(histfile)except IOError: passatexit.register(readline.write_history_file,histfile)del os,histfile,readline,rlcompleter
设定系统变量[python@python ~]$ cat .bash_profile|grep PYTHONexport PYTHONSTARTUP=/home/python/.pythonstartup
认证Tab键补齐和历史时间指令查询。[python@python ~]$ pythonPython 2.7.5 (default, Oct 6 2013, 10:45:13)[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2Type "help", "copyright", "credits" or "license" for more information. import md5 md5.md5.__class__(md5.__getattribute__( md5.__reduce__( md5.__subclasshook__(md5.__delattr__( md5.__hash__(md5.__reduce_ex__( md5.blocksizemd5.__dict__md5.__init__(md5.__repr__(md5.digest_sizemd5.__doc__md5.__name__md5.__setattr__( md5.md5(md5.__file__md5.__new__(md5.__sizeof__( md5.new(md5.__format__( md5.__package__ md5.__str__(md5.warnings import os import md5
留意:假如在make的情况下出現:Python build finished, but the necessary bits to build these modules were not found:_tkintergdbmreadlinesunaudiodev
假如对于此事忽视了得话,import readline会出错。表明沒有特定控制模块!
这儿是缺乏特定包:redhat: readline-devel.xxx.rpm
安裝上再次编译程序实行,难题就可以获得处理。文章内容来源于:www.seo-7.com
(责任编辑:网络)