1

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
1
  • Would you not need to concatenate the strings together? Commented Nov 6, 2012 at 4:30

2 Answers 2

4
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)
Sign up to request clarification or add additional context in comments.

Comments

0

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>
"""

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.