一、python安装
1. 根据你的机型下载python。
2.对应windows用户可以下载一个pythonwin。
3.然后安装就可以用了。
二、numpy,scipy,matplotlib安装
根据个人需要我需要安装numpy、scipy以及matplotlib。
1.下载numpy。
2.下载scipy。
3.下载matplotlib。但是在安装了matplotlib是发现很多问题,后来才知道Matplotlib又依赖dateutil和pyparsing两个库,并且dateutil又需要Six。因此为了让matplotlib可以正常使用需要依次下载deteutil、pyarsing以及Six(使用ctr+f搜索six:Six is a Python 2 and 3 compatibility library)。这样几经周折,matplotlib就可以正常使用了。
三、举例说明
在上面的软件安装后,下面开始使用python了。
1.numpy的使用
>>> from numpy import *
>>> a = arange(15).reshape(3,5)
>>> a
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
>>> a.shape
(3, 5)
>>> a.ndim
2
>>> a.dtype.name
'int32'
>>>
2.matplotlib的使用
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x0273BAB0>]
>>> plt.ylabel('some numbers')
<matplotlib.text.Text object at 0x02573E50>
>>> plt.show #还有一个括号
<function show at 0x0255DEB0>
>>> plt.show()
3.scipy的使用
>>> from scipy import *
>>> a = zeros(1000)
>>> a[:100]=1
>>> b=fft(a) #对数组a进行傅利叶变换,可以由scipy提供f的ft函数来完成
>>> from pylab import *
>>> plot(abs(b)) #看看b是什么样的,可以使用matplotlib库
[<matplotlib.lines.Line2D object at 0x088923D0>]
>>> show()
注意:#Scipy提供numpy所以当导入scipy时导入它是不必要的
另外相关python的学习资源
(1)Python机器学习库
(2)
参考
[1]Python进阶(一)——安装Python、程序执行、Python模块和IDLE调试
[3]python用于数学计算的工具介绍:scipy和numpy
[4]Numpy教程