繁体   English   中英

我正在用 html 制作一个项目,想知道是否可以将 .py 文件导入到 html 代码中

[英]I am making a project in html and was wondering if it is possible to import a .py file into the html code

是否可以将 .py 文件作为链接导入到 html 代码中。 如果是这样,你怎么做。 我试过 link rel="import" href="___.py" 但这不起作用。

rel 属性不包括“导入”。 http://www.w3schools.com/tags/att_link_rel.asp

可能你应该看看 psp(python 服务器页面)技术,但它不是开发 web 应用程序的推荐方式 - 因为逻辑和表示混合在一个文件中。

示例代码

<html>
<%
import math
%>
<h1>square root of 25 is <%= math.sqrt(25) %> </h1>
</html>

你可以这样导入你自己的python模块/脚本

文件

my_var = "bar"

示例.html

<html>
<%
import foo
%>
<h1>my var is <%= foo.my_var %> </h1>
</html>

https://stackoverflow.com/questions/tagged/python-server-pages

http://webware.sourceforge.net/Webware/PSP/Docs/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM