Ich habe eine Beispiel-YAML-Datei und ich kann es nicht mit PyYAML-Bibliothek analysieren.Nicht möglich, YAML-Datei python zu analysieren
setup.yml
:
key: HostName
deviceid: port1
Python-Code
with open('../configs/setup.yml') as stream:
try:
print 'yaml.data ==', yaml.load(stream)
print 'yaml.data ==', type(yaml.load(stream))
# print 'yaml.data ==', dict(yaml.load(stream))
data = yaml.safe_load(stream)
self.device_id = data['deviceid']
self.key = yaml.load(stream)['key']
except yaml.YAMLError as exc:
print(exc)
Der yaml.load(stream)
Typ Nonetype
ist, dachte ich, es ein Wörterbuch sein sollte.