python os.path.exists 返回 false

低的

我正式迷路了.. 我有一个简单的python 来检查文件是否存在。路径存储在字典中。

当我执行下一行代码时,它返回 false:

if not os.path.exists(self.parameters['icm_profile']):
    raise FileDoesNotExistError(PreprocessingErrors.FileNotPresent, "icm profile {} not found".format(self.parameters['icm_profile']))

当我复制 THE EXACT STRING 并执行下一行时,它返回 true:

if not os.path.exists("S:\\IAI\\Data\\Recipes\\BGD\\Inkjet\\LPI\\CMY_360x720dpi_2dpd_profilev6.icm"):
    print("aap")

因此,那么路径确实存在。

我想不出有什么区别......我做错了什么?

在此处输入图片说明

斯文哈里斯

在我看来,您在那里有一对额外的引号,这可能会给您带来麻烦。尝试:

self.parameters['icm_profile'][1:-1]

DeepSpace 提到的另一种方法是使用

self.parameters['icm_profile'].strip('"')

或者如果你真的很偏执

self.parameters['icm_profile'].strip('"').strip("'")

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

python 函数 os.path.exists() 当我给一个 bool 值时返回 True

来自分类Dev

模拟/补丁os.path.exists具有多个返回值

来自分类Dev

os.path.exists返回错误的w /包含空格的转义路径

来自分类Dev

当file_path是相对路径时,os.path.isfile(file_path)返回false,为什么?

来自分类Dev

文件夹存在时,os.path.isdir返回false?

来自分类Dev

os.path.isdir()向现有文件夹返回false

来自分类Dev

os.path.isfile()对于网络驱动器上的文件返回false

来自分类Dev

Python`os.path.isfile()`总是返回TRUE

来自分类Dev

python中的os.path.join返回“错误”路径?

来自分类Dev

Windows 10上的Python:os.rename()找不到os.path.exists()找到的文件吗?

来自分类Dev

从文本文件获取“字符串(路径)”时,File.Exists(Path)始终返回false

来自分类Dev

Directory.Exists()总是返回false?

来自分类Dev

为什么file_exists()返回false?

来自分类Dev

File.Exists()始终返回false

来自分类Dev

python os.path.exists()对于存在的nfs挂载目录文件失败

来自分类Dev

stream_resolve_include_path 返回 false?

来自分类Dev

python if语句总是返回False

来自分类Dev

Python-isinstance返回false

来自分类Dev

python if语句总是返回False

来自分类Dev

File.exists()对于本地帐户中的服务返回false

来自分类Dev

Azure CloudBlockBlob.Exists()方法始终返回false

来自分类Dev

File.Exists()在FileSystemWatcher的Deleted事件中返回false

来自分类Dev

Laravel v5.2.31 Storage :: exists('/')返回FALSE

来自分类Dev

File.Exists()在C#中返回false

来自分类Dev

python“ is”返回True,但是“ ==”返回False

来自分类Dev

更改目录时,Python os.path.dirname返回意外路径

来自分类Dev

python 2.7 os.path.isdir(unicode abspath字符串)什么都不返回

来自分类Dev

python3使用os.path.exists检查并移动,并使用通配符或与数字匹配的shutil.move

来自分类Dev

os.path.exists()将创建该文件

Related 相关文章

  1. 1

    python 函数 os.path.exists() 当我给一个 bool 值时返回 True

  2. 2

    模拟/补丁os.path.exists具有多个返回值

  3. 3

    os.path.exists返回错误的w /包含空格的转义路径

  4. 4

    当file_path是相对路径时,os.path.isfile(file_path)返回false,为什么?

  5. 5

    文件夹存在时,os.path.isdir返回false?

  6. 6

    os.path.isdir()向现有文件夹返回false

  7. 7

    os.path.isfile()对于网络驱动器上的文件返回false

  8. 8

    Python`os.path.isfile()`总是返回TRUE

  9. 9

    python中的os.path.join返回“错误”路径?

  10. 10

    Windows 10上的Python:os.rename()找不到os.path.exists()找到的文件吗?

  11. 11

    从文本文件获取“字符串(路径)”时,File.Exists(Path)始终返回false

  12. 12

    Directory.Exists()总是返回false?

  13. 13

    为什么file_exists()返回false?

  14. 14

    File.Exists()始终返回false

  15. 15

    python os.path.exists()对于存在的nfs挂载目录文件失败

  16. 16

    stream_resolve_include_path 返回 false?

  17. 17

    python if语句总是返回False

  18. 18

    Python-isinstance返回false

  19. 19

    python if语句总是返回False

  20. 20

    File.exists()对于本地帐户中的服务返回false

  21. 21

    Azure CloudBlockBlob.Exists()方法始终返回false

  22. 22

    File.Exists()在FileSystemWatcher的Deleted事件中返回false

  23. 23

    Laravel v5.2.31 Storage :: exists('/')返回FALSE

  24. 24

    File.Exists()在C#中返回false

  25. 25

    python“ is”返回True,但是“ ==”返回False

  26. 26

    更改目录时,Python os.path.dirname返回意外路径

  27. 27

    python 2.7 os.path.isdir(unicode abspath字符串)什么都不返回

  28. 28

    python3使用os.path.exists检查并移动,并使用通配符或与数字匹配的shutil.move

  29. 29

    os.path.exists()将创建该文件

热门标签

归档