【发布时间】:2019-05-03 17:58:22
【问题描述】:
如何在 JavaScript 中使用 $.getJSON 来检索 python 文件数据?
$.getJSON('data.py', function (keyData) {
//code
})
数据.py
import urllib.request, json
def jsonURL():
with urllib.request.urlopen("https://cdn.rawgit.com/highcharts/highcharts/057b672172ccc6c08fe7dbb27fc17ebca3f5b770/samples/data/usdeur.json") as url:
data = json.loads(url.read().decode())
return data
【问题讨论】:
-
你不能使用 getJSON 来查询 Python 文件 - 这需要是 $.get
-
仍然没有从 python 文件中获取 JSON 数据来显示。
标签: javascript python jquery json get