0
我有一個示例YAML文件,我無法使用PyYAML庫解析它。無法解析yaml文件python
setup.yml
:
key: HostName
deviceid: port1
Python代碼
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)
的yaml.load(stream)
類型是Nonetype
,我認爲這應該是一本字典。