Python mail script and inserting variables into the html code

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: &nbsp;</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.

Answers


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: &nbsp;</b>{0}</span></font></div>

        </div>
    </body>
</html>
""".format(raw_input("What's the start time?\n"))

Need Your Help

Reporting Services Cscading Parameter refresh

reporting-services reportingservices-2005

I have googled it a lot and found that usually it cannot be done. I came across one of the hacks here:

Install an appx or appxbundle in a Windows Phone 10?

visual-studio-2015 windows-10 uwp windows-10-mobile windows-10-universal

I'm developing an UWP app which is running without any troubles when it's being debugged using VS2015 but when it's installed using an appx or appxbundle.