I am getting the following syntax error when trying to add a hyperlink,I looked at the HTML code for href,HTML code seems right but python is throwing a syntax error..can anyone help?
Python code
msg_body=("<HTML><head></head>"
"<body>Test"
"<br>Hi All, <br>"
"<b>Wiki @<a href="%s">%s</a> (listed @ go\link) <br><br>"
"<b>Release notes:</b> %s <br><br>"
"<b>Host/Riva Build Combo:</b><br>%s<br><br>"
"<b>Loading instructions:</b><br>%s<br><br>"
"<b>CR fixes:</b><br>%s<br><br>"
"Thanks,<br>"
"B team"
"</body></html>"
) % (wikiURL,Releasenotes,table,Load_ins,crInfo)
Error:-
"<b>Wiki @<a href="%s">%s</a> (listed @ go\wbit) <br><br>" ^
SyntaxError: invalid syntax
asked Nov 6, 2012 at 4:27
user1795998
5,1778 gold badges27 silver badges25 bronze badges
-
Would you not need to concatenate the strings together?Whymarrh– Whymarrh2012年11月06日 04:30:13 +00:00Commented Nov 6, 2012 at 4:30
2 Answers 2
msg_body="""<HTML><head></head>
<body>Test
<br>Hi All, <br>
<b>Wiki @<a href="%s">%s</a> (listed @ go\link) <br><br>
<b>Release notes:</b> %s <br><br>
<b>Host/Riva Build Combo:</b><br>%s<br><br>
<b>Loading instructions:</b><br>%s<br><br>
<b>CR fixes:</b><br>%s<br><br>
Thanks,<br>
B team
</body></html>
""" % (wikiURL, Releasenotes, table, Load_ins, crInfo)
answered Nov 6, 2012 at 4:31
Rag Sagar
2,4241 gold badge21 silver badges22 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Wrong line is
"<b>Wiki @<a href="%s">%s</a> (listed @ go\link) <br><br>"
You need to escape the quotes inside quotes like that:
"<b>Wiki @<a href=\"%s\">%s</a> (listed @ go\link) <br><br>"
like that:
'<b>Wiki @<a href="%s">%s</a> (listed @ go\link) <br><br>'
or (as suggested by @ragsagar) like that:
"""
<b>Wiki @<a href="%s">%s</a> (listed @ go\link) <br><br>
"""
answered Nov 7, 2012 at 10:56
Antony Hatchkins
34.4k13 gold badges122 silver badges114 bronze badges
Comments
default