IOError:[Errno 2]没有这样的文件或目录:' Book1.xls'

时间:2015-05-06 05:17:03

标签: python

Traceback (most recent call last):
  File "C:/my_python/read1.py", line 3, in <module>
    book = open_workbook('Book1.xls',on_demand=True)
  File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 449, in open_workbook
    ragged_rows=ragged_rows,
  File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 941, in biff2_8_load
    f = open(filename, open_mode)
IOError: [Errno 2] No such file or directory: 'Book1.xls'

我在尝试打开excel表时在python中收到此错误消息.....我该如何解决?

1 个答案:

答案 0 :(得分:1)

确保Book1.xls位于“C:\ my_python \”中,这也是您的脚本所在的位置,或者使用Bool1.xls所在位置的完整路径。例如:

book = open_workbook('C:\\Users\\Jeeva\\Documents\\Book1.xls',on_demand=True)