默认本地已经安装好python2.7或者python3.6版本
1、numpy下载地址:https://pypi.python.org/pypi/numpy
根据本地系统32/64以及python版本,选择对应的版本下载
打开CMD命令提示窗口,输入:pip2.7 install numpy-1.13.1-cp27-none-win_amd64.whl
或者:pip3.6 install numpy-1.13.1-cp36-none-win_amd64.whl
等待cmd提示出现安装成功
关于numpy的介绍网上一堆,这个是我觉得比较实用的两篇:
http://blog.csdn.net/u010156024/article/details/50419338
http://blog.csdn.net/huruzun/article/details/39801217
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
xlrd和xlwt两个库都可以在gihub上下载:https://github.com/python-excel
2、xlrd是读取excel文件内容的库
下载地址:https://pypi.python.org/pypi/xlrd
下载之后解压文件
使用cmd进入到当前解压文件夹根目录下,输入命令:python setup.py install
等待提示安装成功
3、xlwt是写入excel文件内容的库
下载地址:https://pypi.python.org/pypi/xlwt
下载后解压文件
同样。
使用cmd进入到当前解压文件夹根目录下,输入命令:python setup.py install
等待提示安装成功
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
上面安装完成后直接在cmd命令下输入python,进入python编辑界面,
输入:import numpy
import xlrd
import xlwt
没有出现出错提示,代表安装成功
xlrd使用demo
import xlrd book = xlrd.open_workbook("myfile.xls") print("The number of worksheets is {0}".format(book.nsheets)) print("Worksheet name(s): {0}".format(book.sheet_names())) sh = book.sheet_by_index(0) print("{0} {1} {2}".format(sh.name, sh.nrows, sh.ncols)) print("Cell D30 is {0}".format(sh.cell_value(rowx=29, colx=3))) for rx in range(sh.nrows): print(sh.row(rx))
xlwt使用demo
import xlwt from datetime import datetime style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on', num_format_str='#,##0.00') style1 = xlwt.easyxf(num_format_str='D-MMM-YY') wb = xlwt.Workbook() ws = wb.add_sheet('A Test Sheet') ws.write(0, 0, 1234.56, style0) ws.write(1, 0, datetime.now(), style1) ws.write(2, 0, 1) ws.write(2, 1, 1) ws.write(2, 2, xlwt.Formula("A3+B3")) wb.save('example.xls')