小编Leo*_*Leo的帖子

单击按钮时如何调用 python 脚本(使用 pyscript)

我想在单击按钮(在 html 文件上)时在浏览器上运行 Python 脚本。与此接近的东西:

<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
</py-env>
</head>

<body>

<button type="button" onclick="runPython()">run Python</button>

<script>
function runPython() { 

<py-script>
print("you clicked me")
</py-script>

}
</script>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html python pyscript

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

html ×1

pyscript ×1

python ×1