python操作Excel
如果实在想扩展功能,我选择 xlwings:简单强大,可替代VBA
1 安装 python 3.6.
2 进入 cmd ,pip install xlwings
3 安装是出了问题: 由于安装的时候 默认安装在 c:\program files\...中,这个路径路径中有空格,安装 xlwings是没有成功l
解决步骤: 重新安装python,安装在没有空格的路径中
4 import xlwings as wb 时候报错: No module named 'win32api'
Python是没有自带访问windows系统API的库的,需要下载。库的名称叫pywin32,
解决方案: pip install pypiwin32
三种方式让python 与 Excel 交互:
参加:http://docs.xlwings.org/en/stable/quickstart.html
第一种: 在python中操作Excel, 这种操作l时候,需要打开Excel ,打开这个xls文件,才能操作。
第二种: 在VBA中调用 python。(启用宏的Excel文件”(xlsm格式))
准备工作: To get access to the RunPython
function, you’ll need the xlwings addin (or VBA module), see Add-in.
1 要在Excel中增加Addin
xlwings addin install
.安装 addin 。注意重启动计算机
Open Excel workbook and press Alt + F11 to get Visual Basic Editor (VBE)
Go to the Tools menu and select References from the drop down menu.
“References- VBAProject” dialog will appear.
2 如何增加 VBAmodule,网上说;
http://blog.csdn.net/qq_34893405/article/details/53610046
3 如果要在Excel增加按钮之类的操作:可以在菜单中增加“” 开发工具“这题菜单”:
参考: https://jingyan.baidu.com/article/363872ec326f236e4ba16f0b.html
python 操作 csv文件
import csv
很多的场合,只需要直接读取CSV文件,内置的csv模块可以用的上。
python操作word
python操作数据库
mysql 安装驱动
pip install mysql-connector-python --allow-external mysql-connector-python
python 操作sqlLite3
由于SQLite的驱动内置在Python标准库中,所以我们可以直接来操作SQLite数据库。
import sqllite3
python 常见的 OS操作
import os
os.mkdir()