(1)根據這位兄弟借鑒:http://www.360doc.com/content/12/0121/07/47186672_1012271624.shtml
① 先 cmd 查看自己的 python 版本,
python --version
②下載對應的 pywin32 :地址:
https://github.com/mhammond/pywin32/releases
根據自己的版本下載,比如我的 python 是 Python 3.10.4,就下載 pywin32-300.win-amd64-py 3.10.exe 文件
③安裝,然后來到對應目錄下,執行:
pip install xlwings
如果存在下載失敗的問題,考慮是不是因為超時問題,可以使用國內鏡像源
pip install xlwings -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install https://pypi.tuna.tsinghua.edu.cn/simple xlwings --user
(2)vscode 里面要先安裝好 python 相關的插件,然后需要配置 launch.json 才可以,直接點擊配置,自己會生成相關的文件,保存即可,接下來就可以
import xlwings as xw
來引入了