I'm trying to write something into a .yaml file but am confused by the documentation. It there says the following:
Block mapping can be nested:
# YAML
hero:
hp: 34
sp: 8
level: 4
orc:
hp: 12
sp: 0
level: 2
# Python
{'hero': {'hp': 34, 'sp': 8, 'level': 4}, 'orc': {'hp': 12, 'sp': 0, 'level': 2}}
So I am trying to get a similar result with the yaml file looking like this in the end:
User1:
name: 'name1'
id: 001
strikes: 1
User2:
name: 'name2'
id: 002
strikes: 3
When I try to use what was used in the example from the docs, it results in this:
User1: {id: '001', name: name1, strikes: 1}
User2: {id: '002', name: name2, strikes: 3}
For this, I used the following code:
strikes = {'User1': {'name': 'name1', 'id': '001', 'strikes': 1}, 'User2': {'name': 'name2', 'id': '002', 'strikes': 3}}
with open(path + "/strikes.yml", 'w+') as stream:
yaml.dump(strikes, stream)