gpt4 book ai didi

Python:使用 xlrd 时没有目录/文件

转载 作者:太空宇宙 更新时间:2023-11-04 10:30:43 27 4
gpt4 key购买 nike

我有简单的代码:

from xlrd import open_workbook

open_workbook('Book1.xls')

无论我如何保存文件(xls 或 xlsx)或如何更改文件路径(C:\Users\... 或 C:\Users...),我都会收到:

IOError: [Errno 2] No such file or directory: '(insert whatever is in place of Book1.xls)'

我不知道我做错了什么。我没有尝试任何具体的事情,但我只是希望它不会抛出错误。

最佳答案

您没有包括文件的整个路径。该路径将如下所示:

file="C:\\USER\\TEST\\FILENAME"

file=r":\USER\TEST\FILENAME"

如果您使用单斜杠,则需要使用 'r' 否则会抛出错误。

关于Python:使用 xlrd 时没有目录/文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26824785/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com