我对Javascript还很陌生。我想知道,导入Python生成的列表是如何工作的?下面是我所想的一个粗略版本,我正在尝试使用javascript将3个列表导入到一个HTML文件中(如果任何语法被禁用,请提前道歉):
function createMarkers(){
//import article_list generated by headline.py
//import urls from generated by headline.py
//import coordinates generated by headline.py
for (i = 0; i < 25;) {
article_name = article_list[i]
url = urls[i]
coordinate = coordinates[i]
var marker[i] = WE.marker([coordinate]).addTo(earth);
marker.bindPopup("<b>article_name</b><br><a href="url">url</a>, {maxWidth: 520, closeButton: true});
}
}
我是否需要实现某种web框架来执行python代码并将其输入到javascript代码中?我该怎么做呢?你知道吗
你研究过模板语言吗?我用Jinja2解决了一个类似的问题。你知道吗
这里有一些Docs。 这里是Quickstart教程。你知道吗
下面是一个例子。你知道吗
变量标记使用Jinja2注入到HTML中
Python代码:
Javascript代码:
相关问题 更多 >
编程相关推荐