当我使用openpyxl运行excel时,下面的代码会引发错误。我无法弄清楚原因。
wb=load_workbook(r'C:\Users\Administrator\Desktop\11.xls')
错误讯息:
C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe
C:/Users/Administrator/Desktop/data_process.py
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/data_process.py", line 3, in <module>
wb = load_workbook(r'C:\Users\Administrator\Desktop\11.xls')
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\reader\excel.py", line 171, in load_workbook
archive = _validate_archive(filename)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\openpyxl\reader\excel.py", line 118, in _validate_archive
archive = ZipFile(filename, 'r', ZIP_DEFLATED)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\zipfile.py", line 1082, in __init__
self.fp = io.open(file, filemode)
OSError: [Errno 22] Invalid argument: '\u202aC:\\Users\\Administrator\\Desktop\\11.xls'
答案 0 :(得分:-1)
尝试以下方法, 而不是1'\'尝试使用双\
from openpyxl import load_workbook
wb=load_workbook(r'C:\\Users\\Administrator\\Desktop\\11.xls')
让我知道这是否有效。