參數(shù):
遠(yuǎn)超 Python shell 的增強(qiáng)版本,可以當(dāng)做 "IDE" 使用。
http://wiki.jikexueyuan.com/project/the-python-study-notes-second-edition/images/10.png" alt="" />
備注
演示
In [1]: prun sum(range(1000))
4 function calls in 0.000 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 {range}
1 0.000 0.000 0.000 0.000 {sum}
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
In [2]: time sum(range(1000))
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
Out[2]: 499500
In [3]: timeit -n 10 -r 3 sum(range(1000))
10 loops, best of 3: 25.8 us per loop
習(xí)慣用 ipdb,代碼高亮,更好的異常調(diào)試支持。
http://wiki.jikexueyuan.com/project/the-python-study-notes-second-edition/images/11.png" alt="" />
啟動(dòng)方式:
相關(guān)方法:
easy_install 替代品,功能更豐富一些,建議使用 1.3 以上版本。
http://wiki.jikexueyuan.com/project/the-python-study-notes-second-edition/images/12.png" alt="" />
指定版本:
$ pip install SomePackage==1.04
$ pip install SomePackage>=1.04
清單文件:
$ pip install -r requirements.txt
文本文件,每行一個(gè)包記錄,如:
Package1
Package2==1.0.4
Package3>=2.0
可以用 pip freeze > requirements.txt 將當(dāng)前已安裝的包導(dǎo)出。
通常配合 VirtualEnvWrapper 使用,它提供一些更易于使用的命令。
$ pip install virtualenv virtualenvwrapper
在 ~/.profile 添加虛擬環(huán)境、項(xiàng)目根目錄等環(huán)境配置。
export WORKON_HOME=$HOME/projects/.virtualenv
export PROJECT_HOME=$HOME/projects
source /usr/local/bin/virtualenvwrapper.sh
相關(guān)命令:
http://wiki.jikexueyuan.com/project/the-python-study-notes-second-edition/images/13.png" alt="" />