我正式迷路了.. 我有一个简单的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] 删除。
我来说两句