Created
October 5, 2019 18:45
-
-
Save epifanio/98698db4f23a7cc9f4b97d2cb1d13ba7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = 'n' | |
type = 't' | |
stored = 'true' | |
data = '{\n "add-field":{\n "name":"%s",\n "type":"%s",\n "stored":%s }\n}' % (name, type, stored) | |
data |
while using str.format()
:
data = '{\n "add-field":{\n "name":"{name}",\n "type":"{type}",\n "stored":{stored} }\n}'.format(name=name, type=type, stored=stored)
i got:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-26-1c58c43a20c5> in <module>
----> 1 data = '{\n "add-field":{\n "name":"{name}",\n "type":"{type}",\n "stored":{stored} }\n}'.format(name=name, type=type, stored=stored)
KeyError: '\n "add-field"'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
attempt to use
f-string
:return the error: