简体   繁体   English

在HTML文件中导入Python代码

[英]Import Python codes inside HTML file

As mentioned here , I can import Python codes inside .html files using <% and %> tags. 如前所述在这里 ,我可以使用导入内部.html文件的Python代码<%%>标签。 Just to try it, I wrote the below code in notepad and save it as a file named test.html : 为了尝试,我在记事本中编写了以下代码,并将其保存为名为test.html的文件:

<html>
<title>
</title>
<body>
<%print ("Hello")%>
</body>

Once I do a double click on the test.html, Chrome opens with the below line on the top : 双击test.html后,Chrome将打开,并在顶部显示以下行:

<%print ("Heloo")%>

What I must I do to have 'Hello' in output? 我必须怎么做才能在输出中显示“ Hello”?

Note: "print" is an example, What kind of ways is there to import and run python codes in html files? 注意: “打印”是一个示例,在html文件中导入和运行python代码有哪些方式?

That page is related to Karrigell a Python web framework, you can only have Python and HTML files (Web pages) if you use a Python web framework like web.py , Pylons , Django , and others . 该网页是有关Karrigell一个Python的web框架,你可以,如果你使用像一个Python的Web框架只有Python和HTML文件(网页) web.py主塔Django的 ,和其他人

Browsers can only execute JavaScript code, other programming languages have to use special components to be executed by browsers. 浏览器只能执行JavaScript代码,其他编程语言必须使用特殊组件才能由浏览器执行。

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

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