KeyError when using .format on a string in Python

Viewed 11460

I have a string and I want to use .format function of python to add some variables in it on runtime, This is my string :

'{"auth": {"tenantName": "{Insert String Here}", "passwordCredentials": {"username": "{insert String here}", "password": "{insert String Here}"}}}'

when I use .format like this:

credentials='{"auth": {"tenantName": "{tenant}", "passwordCredentials": {"username": "{admin}", "password": "{password}"}}}'.format(tenant='me',admin='test',password='123')

It gives me the following error:

KeyError: '"auth"'

Any Help? Thanks in Advance.

5 Answers
Related