简体   繁体   English

意外的令牌'<'

[英]Unexpected token '<'

I am using this to add html between a div tag but it displays Unexpected token '<'我正在使用它在 div 标签之间添加 html 但它显示Unexpected token '<'

browser.execute_script("arguments[0].innerHTML = " + f'{x["solution"]}', solution)

The x["solution"] is a json file which contains html like <strong> bold </strong> etc. x["solution"]是一个 json 文件,其中包含 html,如<strong> bold </strong>等。

You forgot to quote the right part of the equality.您忘记引用等式的正确部分。 This code is generating:此代码正在生成:

arguments[0].innerHTML = <strong> bold </strong>

Also, you can use a single formatted string which would look like:此外,您可以使用如下所示的单个格式化字符串:

browser.execute_script(f'arguments[0].innerHTML = "{x["solution"]}"', solution)

and would generate并且会产生

arguments[0].innerHTML = "<strong> bold </strong>"

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

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