我已经为我的主要python代码准备了一个YAML文件,加载时出现错误,请在YAML文件中建议更正。
此处不允许使用映射值-第4行,第9列
yaml.scanner.ScannerError: mapping values are not allowed here
in "C:\Users\rajangra\PycharmProjects\jinja2/yaml_input/input.yaml", line 4, column 9
Process finished with exit code 1
我尝试更改许多参数,但仍然出现相同的错误
---
region:
- SGC
ring:
- Rosebank Ring 7
hostname:
- SGC_CrownLongmeM_SARA-1
system_ip: 10.172.97.217
ptp_ip: 10.172.101.217
isis_id: 3
port: 1/3/4
interface:
- SGC_ABR_12-1
dest_ip: 10.172.97.1
- SGC_ABR_12-2
dest_ip: 10.172.97.2
- SGC_SunningParkOLD_SAR8-1
system_ip: 10.172.64.16
ptp_ip: 10.172.68.16
isis_id: 3
port: 1/3/4
interface:
- SGC_ABR_12-1
dest_ip: 10.172.64.1
- SGC_ABR_12-2
dest_ip: 10.172.64.2
yaml.scanner.ScannerError: mapping values are not allowed here
in "C:\Users\rajangra\PycharmProjects\jinja2/yaml_input/input.yaml", line 4, column 9
Process finished with exit code 1
答案 0 :(得分:0)
诸如SGC ring
和Rosebank Ring 7 hostname
之类的多行普通标量不能用作映射键,请引用它们
region:
- 'SGC
ring':
- 'Rosebank Ring 7
hostname':
或将它们放在一行上:
region:
- SGC ring:
- Rosebank Ring 7 hostname:
(另一种可能性是您忘记在ring
和hostname
之前插入破折号)。