【语言处理与Python】4.8Python库的样例

Matplotlib绘图工具、NetwordX工具可以自行查阅相关资料。

CSV

读取CSV的格式

import csv
input_file=open('lexicon.csv','rb')
for row in csv.reader(input_file):
    print row

NumPy

NumPy中的多维数组对象

>>>from numpy import array
167
>>>cube = array([ [[0,0,0], [1,1,1], [2,2,2]],
... [[3,3,3], [4,4,4], [5,5,5]],
... [[6,6,6], [7,7,7], [8,8,8]] ])
>>>cube[1,1,1]
4
>>>cube[2].transpose()
array([[6, 7, 8],
[6, 7, 8],
[6, 7, 8]])
>>>cube[2,1:]
array([[7, 7, 7],
[8, 8, 8]])

其他Python库

可以使用http://pypi.python.org处的Python包索引找到他们。

posted @ 2013-05-25 15:12  createMoMo  阅读(254)  评论(0编辑  收藏  举报