1 包的管理
1.1 安装
方法一:pip install package
方法二:(上面那个方法解决不了,就这个方法)下载指定包,手动安装
https://pypi.org/
https://www.lfd.uci.edu/~gohlke/pythonlibs/
如果没安装wheel记得先安装wheel:pip install wheel
pip install xxx.whl
1.2安装问题
cx_Oracle-7.2.1-cp37-cp37m-win32.whl #我下载的这个版本无法安装,比较诡异
ERROR: cx_Oracle-7.2.1-cp37-cp37m-win32.whl is not a supported wheel on this platform.
import pip
import pip._internal; print(pip._internal.pep425tags.get_supported())
[('cp37', 'cp37m', 'win_amd64'), ('cp37', 'none', 'win_amd64'), ('py3', 'none', 'win_amd64'), ('cp37', 'none', 'any'), ('cp3', 'none', 'any'), ('py37', 'none', 'any'), ('py3', 'none', 'any'), ('py36', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
将文件改名 cx_Oracle-7.2.1-cp37-cp37m-win32.whl 既可以解决!
2 Excel操作
2.1xlrd xlwt
大概思路:
1、用xlrd.open_workbook打开已有的xsl文件
注意添加参数formatting_info=True,得以保存之前数据的格式
2、然后用,from xlutils.copy import copy;,之后的copy去从打开的xlrd的Book变量中,拷贝出一份,成为新的xlwt的Workbook变量
3、然后对于xlwt的Workbook变量,就是正常的:
通过get_sheet去获得对应的sheet,拿到sheet变量后,就可以往sheet中,写入新的数据
4、写完新数据后,最终save保存
import xlrd
import os
from xlutils.copy import copy
from xlwt import Style
def writeExcel(row, col, str, styl=Style.default_style):
rb = xlrd.open_workbook(file, formatting_info=True)
wb = copy(rb)
ws = wb.get_sheet(0)
ws.write(row, col, str, styl)
wb.save(file)
style = xlwt.easyxf('font:height 240, color-index red, bold on;align: wrap on, vert centre, horiz center');
writeExcel(1, 1, 'hello world', style)