Reputation: 605
I tried to use templates and string formatting but nothing seemed to work.
I'm trying to prompt for user input so they can set a time in the html code. Here's a snippit of the code:
my_html = """\
<html>
<head>
<title>Something goes here</title>
</head>
<body>
<div style="font-family: 'Segoe UI', Helvetica, Arial, sans-serif;">
<font face="Calibri,sans-serif" size="2"><span style="font-size: 14px;"><b>When: </b>$the_time_goes_here</span></font></div>
</div>
</body>
</html>
"""
the_time_goes_here = raw_input("What's the start time?\n")
I want to get "the_time_goes_here" to populate data in the html code.
Upvotes: 1
Views: 60
Reputation: 180441
Use str.format using a placeholder {}
for the string pass into raw_input :
my_html = """\
<html>
<head>
<title>Something goes here</title>
</head>
<body>
<div style="font-family: 'Segoe UI', Helvetica, Arial, sans-serif;">
<font face="Calibri,sans-serif" size="2"><span style="font-size: 14px;"><b>When: </b>{0}</span></font></div>
</div>
</body>
</html>
""".format(raw_input("What's the start time?\n"))
Upvotes: 3