insert multiple elements in string in python
Posted
by
Anurag Sharma
on Stack Overflow
See other posts from Stack Overflow
or by Anurag Sharma
Published on 2013-07-01T10:16:11Z
Indexed on
2013/07/01
10:21 UTC
Read the original article
Hit count: 322
python
|python-2.7
I have to build a string like this
{ name: "john", url: "www.dkd.com", email: "[email protected]" }
where john, www.dkd.com and [email protected] are to be supplied by variables
I tried to do the following
s1 = "{'name:' {0},'url:' {1},'emailid:' {2}}"
s1.format("john","www.dkd.com","[email protected]")
I am getting the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: "'name"
Dont able to understand what I am doing wrong
© Stack Overflow or respective owner