git clone https://github.com/numpy/numpy.git numpy
git clone https://github.com/scipy/scipy.git scipy
python setup.py install
1 python中python 中__name__ = '__main__' 的作用
2 python注释
3 python中import和from...import区别
4 python打包工具pyinstaller:
使用 PyInstaller 把python程序 .py转为 .exe 可执行程序
pyinstaller工具:https://github.com/pyinstaller/pyinstaller
8 a, b =
b, a
+b
# 这种赋值,先计算等值右边 那么 b=1 a+b=1
# 再赋值给a和b,那么 a=1, b=1
实例:using_sys.py
#!/usr/bin/python
#Filename:using_sys.py
#python using_sys.py we are
import sys
import os
print 'the command line:'
"""
print 'hello'
"""
def test_main():
print "we are in %s"%__name__
if __name__=="__main__":
test_main()
print __file__
for i in sys.argv:
print i#
print '\n\n PythonPath is',sys.path,'\n'
#fibonacci数列
a,b = 0,1
while b<10:
print(b),
a,b=b,a+b
print"\n"
#fibonacci数列
a=1
b=1
c=0
while c<30:
c=a+b
a=b
b=c
print(c)
#reverse
def reverse(str):
str=str[::-1]
直接运行: python using_sys.py
生成二进制文件using_sys:
cd PyInstaller.py-2.1/
./pyinstaller.py ../romBuild.py
./pyinstaller.py -F ../romBuid.py 其中:-F表示生成文件;
./pyinstaller.py -F ../src/using_sys.py
cd PyInstalller-2.1/using_sys/dist/ - - - 生成文件目录,using_sys/dist是以using_sys.py的文件名命名的目录
./using_sys
【常用命令】
1 退出:
1:输入exit(),回车
2:输入quit(),回车
3:输入ctrl+z,回车
2 python -m 执行py文件
python setup.py install 安装Python包
3
python 环境变量设置PYTHONPATH --普通用户设置;
export PYTHONPATH=$PYTHONPATH:/home/xx/tools/python/lib/xxx;
python setup.py install --prefix=/home/xx/tools/python;
export PATH=$PATH:/home/xx/tools/python/bin
python IDE :Eclipse with PyDev
spider:
domain.py
1>import urlparse 2>urlparse.urlparse
link_finder.py:1 >import HTMLParser 2>import urlparse 3>class LinkFinder<HTMLParser.HTMLParser>
4>super(LinkFinder,self) 5 urlparse.urljoin
main.py:1>import Queue 2>queue=Queue.Queue()
spider.py:1>from urllib2 import urlopen
5 spider.py: reponse=urlopen() reponse.info().getheader()