【发布时间】:2018-04-15 22:43:36
【问题描述】:
我有一个列表:
token_found = ["abcdxyz", "1234567"]
我有一个多行字符串如下:
user_creds_string = """
UserA_A:
- name: 'Abcd'
value: '{0}'
UserB_B:
- name: 'Abcd'
value: '{1}'
headers:
- name: 'Abcd'
value: 'Kota %(xyz)'
inputs:
apop: {'type':'hex-64', 'required': True}
- name: 'X-Broke'
value: '%(BId) %(blahId)'
inputs:
UkID: {'type':'hex-16', 'required': True}
blahId: {'type':'hex-64', 'required': True}
apis:
""".format(token_found[0],token_found[1])
现在,当我运行上面的代码时,我希望占位符 {0} 和 {1} 分别替换为值 abcdxyz 和 1234567,除非我做错了什么并且我不明白.
与我的假设相反,我收到以下错误:
KeyError: "'type'"
【问题讨论】:
标签: python string python-2.x string-literals