yaml文件的更新版本未被读取

问题描述 投票:0回答:1

我正在阅读Python3中的yaml文件:

def get_file():
    file_name = "file.yml"

    properties_stream = open(file_name, 'r')
    properties_file = yaml.safe_load(properties_stream)
    properties_stream.close()
    print(properties_file)
    return properties_file

当我通过添加键或删除文件的所有内容来更新file.yml时,“print(properties_file)”语句在我第一次运行此代码时仍保留yaml文件的内容。

任何想法为什么会这样?

python python-3.x yaml pyyaml
1个回答
0
投票

安森是对的。原来,我的项目目录中有两个同名的文件夹位于不同的子目录中,而且它是从错误的文件中读取的。

© www.soinside.com 2019 - 2024. All rights reserved.