gpt4 book ai didi

Python:在变量中存储路径;参数错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:30:46 24 4
gpt4 key购买 nike

path = input("Enter the path")
book = xlrd.open_workbook(path)

给出路​​径并运行程序后,我收到以下错误:

OSError: [Errno 22] 无效参数: '"D:\\\shreyatest1.xlsx"'

路径为:“D:\\shreyatest1.xlsx”

最佳答案

\\ 字符是 python 在字符串文字中表示转义 \ 的方式。从控制台输入字符串时,不需要(阅读:这是错误的)使用此表示法。只需输入您看到的路径 - D:\shreyatest1.xlsx

关于Python:在变量中存储路径;参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37614716/

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