try.html文件:-
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<input type="button" class="btn" id="processbtn" value="Process"
onclick="get_tt()"/>
<script src="try3.js"></script>
</body>
</html>
try3.js文件:-
function get_tt() {
document.getElementById("processbtn").value = "Hang on..."
var python=require("python-shell")
var path = require("path")
var options = {
scriptPath : path.join(__dirname,''),
pythonPath : 'C:/Users/Lenovo/Anaconda3/python'
}
var f = new python("hello.py",options);
f.end(function(err, code, message) {
document.getElementById("processbtn").value = "Done";
})
}
python代码未使用此代码执行。按钮的值更改为“挂起...”,并保持相同状态。