0
當我使用openpyxl操作excel時,下面的代碼會引發錯誤。我無法弄清楚原因。OSError:[Errno 22] load_workbook中的參數無效
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'
如果你看看錯誤信息,你會發現你的路徑中有一個'\ u202a'字符。 –
請參閱[此鏈接](http://www.fileformat.info/info/unicode/char/202a/index.htm)關於''\ u202a'' char – Shai
如果您使用'\\'而不是'/'? –