你可以在阅读(编辑:谢谢你的理解)之前对此进行选择,因为标题但其他问题只是回答如何在html中运行python程序,但我想要做的是在html中使用python终端。
所以那些家伙在我的头脑中确实存在很大的问题。我怎样才能在html中使用python程序,就像它是终端一样。
这是我的项目,它将是一个互动词典,你可以学习词汇。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial
}
* {
box-sizing: border-box;
}
/* The browser window */
.container {
border: 3px solid #f1f1f1;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
/* Container for columns and the top "toolbar" */
.row {
padding: 10px;
background: #f1f1f1;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.scriptcontainer {
padding: 10px;
background: #ffffff;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.row2 {
padding: 5px;
background: #cc0000;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
/* Create three unequal columns that floats next to each other */
.column {
float: left;
}
.left {
width: 15%;
}
.right {
width: 10%;
}
.middle {
width: 75%;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Three dots */
.dot {
margin-top: 4px;
height: 12px;
width: 12px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
/* Style the input field */
input[type=text] {
width: 100%;
border-radius: 3px;
border: none;
background-color: white;
margin-top: -8px;
height: 25px;
color: #666;
padding: 5px;
}
.bar {
width: 17px;
height: 3px;
background-color: #aaa;
margin: 3px 0;
display: block;
}
/* Page content */
.content {
padding: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="column middle">
<h4><font size="6" type="Times">VocaDict</font></h4>
</div>
</div>
<div class="content">
<h3>=>Your dictionary:</h3>
<div class="row2"><div class="content"><div class="scriptcontainer"> <script>//This is where your dictionary will go!</script></div></div></div>
</div>
<div class="content">
<h3>=>Study lists:</h3>
<div class="row2"><div class="content"><div class="scriptcontainer"> <script>//This is where your dictionary will go!</script></div></div></div>
</div><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br><br>
</div>
</body>
</html>
我问的是这个地方:
<div class="content"><div class="scriptcontainer"> <script>//This is the place I want python terminal to be!</script>
我希望这个地方就像一个python终端。当页面加载时,它将运行程序,它不会影响任何其他东西,并且像独立的东西,但它将保留在页面上,并将是交互式的。
这是可能的,如果可能,怎么样?
谢谢!
答案 0 :(得分:1)
你到底想要做什么?如果你真的想用HTML运行python脚本,那就去CGI吧。由于您无法直接运行python,因此可能需要使用以下内容,
http://karrigell.sourceforge.net/en/pythoninsidehtml.html
或
http://www.skulpt.org/
但最好的方法是使用python-cgi编程https://www.tutorialspoint.com/python/python_cgi_programming.htm
答案 1 :(得分:0)
不可能。
我自己以前有这个问题。显然,其目的是为其他脚本腾出空间,至少我是这样认为的:
<script type="text/javascript">
<script type="text/python">
需要使用浏览器来实现。也许这个引擎:https://www.gnu.org/software/pythonwebkit/