你好,我是 python 的新手,正在尝试学习它,我使用 openpyxl 包编写了一个小代码来自动执行 excel 上的任务,并且正在使用一个小电子表格“transactions.xlsx”,但是当我尝试阅读时出现错误床单。请帮我解决这个问题
这是我的代码如下:
import openpyxl as xl
wb= xl.load_workbook('transactions.xlsx')
sheet = wb ['Sheet1']
cell = sheet['a1']
print(cell.value)`
我收到的消息:
PS C:\Users\ryan\helloworld> & C:/Users/ryan/anaconda3/python.exe c:/Users/ryan/helloworld/app.py
Traceback (most recent call last):
File "c:\Users\ryan\helloworld\app.py", line 2, in <module>
wb= xl.load_workbook('transactions.xlsx')
File "C:\Users\ryan\anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 124, in __init_rkbook_
self.archive = _validate_archive(fn) _
File "C:\Users\ryan\anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 96, in _validate_archive e_archive
archive = ZipFile(filename, 'r')
File "C:\Users\ryan\anaconda3\lib\zipfile.py", line 1267, in __init__
self._RealGetContents()
File "C:\Users\ryan\anaconda3\lib\zipfile.py", line 1334, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file