I have a variable defined as follows:
item_title="Title"
And I want to put this value into the following string:
html_desc="""
<![CDATA[
<head>
<style>
body {
font-size: 25px;
border-style: solid;
border-width: 5px;
border-color: green;
border-radius: 10px;
background-color: #FFFFC2;
padding: 15px;
}
li {
color: #F7270F;
font-weight: bold;
}
</style>
</head>
<body>
<h1 align="center">Auctions for Week of 08-01-2018</h1>
<p>You are bidding on the following item:</p>
<ul><li>"{}".format(item_title)</li></ul>
<p>Condition is pack fresh unless otherwise indicated. Please review the pictures carefully and if you have any questions about something specific, ask.</p>
<p><b>Shipping:</b> Shipping will be calculated based on buyer location. No premiums are charged. Cards are mailed in an 8x5 bubble mailer and shipped First Class mail unless the price exceeds $50, at which point they will be shipped Priority at no additional cost to the buyer. If you win multiple auctions, please wait for an invoice to be sent.</p>
</body>
]]>"""
My attempt here is broken. I've also tried using {} and the .format at the end after the final three """ but that isn't working either.
Any assistance?
you can not use format because you used these {}
brackets in style section, but you can do it easily by Plus Operator ( +
) like:-
html_desc="""
<![CDATA[
<head>
<style>
body {
font-size: 25px;
border-style: solid;
border-width: 5px;
border-color: green;
border-radius: 10px;
background-color: #FFFFC2;
padding: 15px;
}
li {
color: #F7270F;
font-weight: bold;
}
</style>
</head>
<body>
<h1 align="center">Auctions for Week of 08-01-2018</h1>
<p>You are bidding on the following item:</p>
<ul><li>""" + item_title + """</li></ul>
<p>Condition is pack fresh unless otherwise indicated. Please review the pictures
carefully and if you have any questions about something specific, ask.</p>
<p><b>Shipping:</b> Shipping will be calculated based on buyer location. No premiums are charged. Cards are mailed in an 8x5 bubble mailer and shipped First Class mail unless the price exceeds $50, at which point they will be shipped Priority at no additional cost to the buyer. If you win multiple auctions, please wait for an invoice to be sent.</p>
</body>
]]>"""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.