python2.5 doc帮助设置
刚开始学Python所以先看了这本书《A Byte of Python》(下载地址
http://bbs.chinaunix.net/thread-646538-1-1.html)里面有一个设置如下
$ env PYTHONDOCS=/usr/share/doc/python-docs-2.3.4/html/ python
Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help('print')
不过按照它的配置我却找不到python-docs-2.x.x/html这个目录
-bash-3.2:~/python$ ls /usr/share/doc/python
python/ python-crypto/ python-numpy/
python2.4/ python-gnupginterface/ python-numpy-dev/
python2.4-minimal/ python-gnuplot/ python-pyx/
python2.5/ python-minimal/ python-scientific/
python2.5-minimal/ python-netcdf/ python-scipy/
python-apt/ python-numeric/ python-support/
python-central/ python-numeric-ext/如果运行
-bash-3.2$ python
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help('print')出现如下错误
Sorry, topic and keyword documentation is not available because the Python
HTML documentation files could not be found. If you have installed them,
please set the environment variable PYTHONDOCS to indicate their location.
On the Microsoft Windows operating system, the files can be built by
running "hh -decompile . PythonNN.chm" in the C:\PythonNN\Doc> directory.
去百度和谷歌搜索也没有找到具体的结果
到Python英文官方网站看了看发现有个与docs相关的地址,如下:
http://docs.python.org/ftp/python/doc/2.5/html-2.5.tar.bz2
所以下载下来试试看
-bash-3.2$ pwd
/home/d/x/fish2shoes/python
-bash-3.2$ ls
helloworld.py Python-Docs-2.5.2 pythondoc.sh start.sh
我把它解压到了/home/d/x/fish2shoes/python目录下
然后我又按照上面的命令试了一下,命令如下:
-bash-3.2$ env PYTHONDOCS=~/python/Python-Docs-2.5.2/ python
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help('print')
>>>
-----------------------------------------------------------------------------
6.6 The print statement
print_stmt ::= "print" ([expression[1] ("," expression[2])* [","]
| ">>" expression[3] [("," expression[4])+ [","])
Download entire grammar as text.[5]
终于能用了。
不过这个命令只是临时生效,要想能一直用可以
-bash-3.2$ export PYTHONDOCS=~/python/Python-Docs-2.5.2/在运行env
-bash-3.2$ env
HOSTNAME=fc8
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
OLDPWD=/home/d/x/fish2shoes
SSH_TTY=/dev/pts/1
USER=fish2shoes
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01r=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.svgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.dz=00;31:*.gz=00;31:*.bz2=00;31:*.tbz2=00;31:*.bz=00;31:*.tz=00;31:*.deb=00;31:*.rpm=00;31:*.jar=00;31:*.rar=00;31:*.ace=00;31:*.zoo=00;31:*.cpio=00;31:*.7z=00;31:*.rz=00;31:*.jpg=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.mng=00;35:*.pcx=00;35:*.mov=00;35:*.mpg=00;35:*.mpeg=00;35:*.m2v=00;35:*.mkv=00;35:*.ogm=00;35:*.mp4=00;35:*.m4v=00;35:*.mp4v=00;35:*.vob=00;35:*.qt=00;35:*.nuv=00;35:*.wmv=00;35:*.asf=00;35:*.rm=00;35:*.rmvb=00;35:*.flc=00;35:*.avi=00;35:*.fli=00;35:*.gl=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.svg=00;35:
环境变量多了一个PYTHONDOCS=/home/d/x/fish2shoes/python/Python-Docs-2.5.2/
MAIL=/var/spool/mail/fish2shoes
PATH=/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/bin:/usr/bin
INPUTRC=/etc/inputrc
PWD=/home/d/x/fish2shoes/python
LANG=en_US.UTF-8
KDE_IS_PRELINKED=1
KDEDIRS=/usr
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/home/d/x/fish2shoes
SDL_AUDIODRIVER=esd
LOGNAME=fish2shoes
CVS_RSH=ssh
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env
这样就可以随时使用help()了。
刚开始学习Python有什么不对的地方请高手指教!!