如果Python要处理Excel,需要一个“xlrd"包, [ xls read], download line: http://pypi.python.org/pypi/xlrd
cd 到目录下边:
输入:python setup.py install 安装即可
读取很简单,网上随便一搜都会有,例如按行读取:
import xlrd
#import chardet
data = xlrd.open_workbook("emotion.xlsx")
table = data.sheets()[0]
nrows = table.nrows
for i in range(nrows):
#print chardet.detect(str(table.row_values(i)))
print table.row_values(i)

在Python中处理Excel文件时,通常使用xlrd库。在Linux环境下,通过`python setup.py install`安装xlrd。读取Excel内容时,终端显示可能会出现乱码。解决办法是将打印语句中的字符串转为UTF8编码,因为Linux终端默认使用UTF8。首先需要将字符串decode为Unicode,再encode为UTF8,decode时通常采用unicode_escape编码格式。
最低0.47元/天 解锁文章

2万+

被折叠的 条评论
为什么被折叠?



