我相信这是微不足道的,但我不能把我的参数到我的HTML字符串。我从https://templates.campaignmonitor.com/下载了一个标准模板。我试过:
摘自'索引.html':
< p align="left" class="article-title">< singleline label="Title">%(headline)< /singleline>< /p>
以下是一些代码作为输入:
f = open('index.html','r')
html = str(f.read())
html_complete = html % (headline='Today is the day')
这会导致语法错误。(html打印很好)。你知道吗
我也尝试了{}表示法,但我得到了一个键错误,可能是因为html中到处都是“{”。你知道吗
在你的队伍里
试试这个:
避免语法错误。你知道吗
并根据Jan Hudec在回答中的陈述修复HTML模板(添加
s
)。你知道吗注意:
dict(a=b)
与{ "a": b }
相同,只是有助于避免双引号。你知道吗相关问题 更多 >
编程相关推荐