Python open函数打开yaml文件:FileNotFoundError: [Errno 2] No such file or directory 错误的解决

问题描述:
文件为yaml文件,路径存放变量中,打印变量确认路径没问题,但还是一直报错。
self.file_path = root_dir + '\\test_data\\test_yaml_data.yaml'

解决方法
右键查看文件属性发现,该yaml文件在系统中无后缀

因此修改路径,去掉.yaml:
self.file_path = root_dir + '\\test_data\\test_yaml_data'

运行成功

posted @ 2021-04-02 16:09  TesterBenja  阅读(1682)  评论(0)    收藏  举报