我有yaml config:
import yaml
if __name__ == "__main__":
stream = open(sys.argv[0], 'r')
docs = yaml.load_all(stream)
for doc in docs:
print doc
通过http://yaml-online-parser.appspot.com/和http://www.yamllint.com/验证
但是当我尝试时:
yaml.scanner.ScannerError: mapping values are not allowed here
in "/opt/projects/nextgis/gazetteer-update/gup-web.py", line 7, column 40
我收到了错误:
<table>
<tr><td id="space_bet1" height="10"></td></tr>
<tr><td id="unscr1">Today</td></tr>
<tr><td id="space_bet2" height="10"></td></tr>
<tr><td id="unscr2">Tomorrow</td></tr>
<tr><td id="space_bet3" height="10"></td></tr>
<tr><td id="unscr3">Yesterday</td></tr>
<tr><td id="space_bet4" height="10"></td></tr>
<tr><td id="unscr4">next week</td></tr>
<tr><td id="space_bet5" height="10"></td></tr>
<tr><td id="unscr5">next month</td></tr>
<tr><td id="space_bet6" height="10"></td></tr>
</table>
答案 0 :(得分:1)
找到了我的错误:
stream = open(sys.argv[0], 'r')
sys.argv[0]
本身就是python脚本,所以我试图解析脚本,而不是yaml配置。
正确的arg值在索引1下:
stream = open(sys.argv[1], 'r')