0
YAMLファイルを読み込んで特定の値を更新する関数を書く必要があります。 YAMLファイルは yamlファイルを辞書として読み込み、Pythonを使って値を更新する方法
sample :
test_example:
parent:
attribute_1: 2
attribute_2: 2
parent2:
childList:
- group: 2
type: "test"
track_int:
- key_1: 3
key_2: 25
state: present
state: present
- group: 4
typr: "old"
track_int:
- key_1: 3
key_2: 25
state: present
state: present
は、今私は、キーを渡すために関数を記述する必要があり、辞書であり、それは特定の値 元の値を置き換える必要があります -
test_example["parent"]["attribute_2"]
から
5
を
test_example["parent2"]["childList"][0]["group"]
4
にを更新し、更新します
どうすればいいですか?
このYAMLファイル/ドキュメントは辞書ではなく、マッピングとシーケンス(およびスカラー)の組み合わせです。ルートにはPython辞書としてロードされるマッピングがありますが、 "YAMLファイルは辞書です"というのは間違っています。 – Anthon