我有一个python脚本,可以创建 UTF-8
编码< script>
和< div>
标记。如何将它们嵌入我的 index.html
?示例:
< script>
和< div>
元素在 script.py中创建
:
s =“< script type =”text / javascript“> function(){console.log(”Hello“) }< / script>“
 su = unicode(s,”utf-8“)

 d =”< div>< p> World< / p>< / div>“
 du = unicode(d,”utf-8“)



 index.html 代码>功能如下:
< meta charset =“utf-8”/>

< head>& #xA;< script type =“text / javascript”> function(){console.log(“Hello”)}< / script>
< / head>

 <主体>
< DIV>< p为H.世界< / p>< / DIV>
< / BODY>
 代码>
&#XA ;
 script.py
与 index.html
不在同一服务器上。如何在 index.html
中嵌入 su
和 du
?所需的 index.html
类似于:
< meta charset =“utf-8”/>&# xA;
< head>
<! - 插入从script.py获取su的JavaScript - >
< / head>

< ; body>
<! - 插入从script.py中获取du的JavaScript - >
< / body>


 
 其他信息: script.py
通过Apache访问并作为cgi脚本执行。
答案 0 :(得分:0)
使用django web框架处理python或对包含py脚本的服务器使用ajax请求