简体   繁体   English

Python HTML代码语法错误

[英]Python HTML code syntax error

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? 我在尝试添加超链接时遇到以下语法错误,我查看了href的HTML代码,HTML代码似乎正确但是python正在抛出语法错误。有人可以帮忙吗?

Python code Python代码

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

Something else to point out; 还有其他要指出的事情; you may want to use: 你可能想用:

    <p> & </p>

instead of: 代替:

    <br>

as it makes a paragraph. 因为它是一个段落。 For instance: 例如:

    <p> Hello world. This is a paragraph.</p>

it also makes a break from the last item. 它也会从最后一项中断。

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: 或者(正如@ragsagar所建议的):

"""
<b>Wiki @<a href="%s">%s</a> (listed @ go\link) <br><br>
"""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM