[英]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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.