【发布时间】:2017-02-22 19:34:00
【问题描述】:
我正在使用 HTML5、Django、Python 3.4
1) 我想要 2 使用 Javascript/Jquery/AJAX/DJANGO/Anyshitstuff 在 html5 文档中调用 python 脚本
代码(pyscript.py)=
print("Hello everyone")
注意文件pyscript.py 和mywebpage.html r 在同一个名为templates 的目录中
2)我想要 2 在另一个 python 脚本中调用一个 python 脚本,我该怎么做?
1.py
a=5
2.py
//here i include python script that is 1.py then
print(a)
【问题讨论】:
-
您不能从 HTML 文档调用 python 脚本。但是您可以使用 javascript 向您的 django 服务器发出请求:了解 AJAX。对于第 2 点,请了解 python modules。
-
我认为在提出这些问题之前,您需要解决一些基本的误解:如果您使用 Django,为什么要“调用” Python 脚本?使用 AJAX 可以做到这一点,但我怀疑您对前端和后端之间的关系不太清楚。
标签: python django html django-models