小编caf*_*172的帖子

如何在 HTML 代码中使用 pyscript 并返回输出

我正在尝试调用我创建的 python 函数。但没有得到任何输出,也没有资源如何实现。

\n

代码 :

\n
<!DOCTYPE html>\n<html>\n<head>\n<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />\n<script defer src="https://pyscript.net/alpha/pyscript.js"></script>\n</head>\n<body>\n\n<p>Click on the "Choose File" button to upload a file:</p>\n\n<form>\n  <input  type="file" id="myFile" name="filename">\n  <input type="submit" onClick="readfile(filename)" name="SUBMIT">\n</form>\n\n<py-script>\n\ndef readfile(filename):\n    with open(filename) as mfile:\n        head = [next(mfile) for x in range(1,5)]\n        print(head)\n\n</py-script>\n\n</body>\n</html>\n
Run Code Online (Sandbox Code Playgroud)\n

如果有人提供像 \xe2\x80\xa6 这样的输入,那将会非常有帮助

\n

如何将选定的文件传递给我的函数,并且 python 将被执行并在屏幕上返回输出。

\n

html css python pyscript

6
推荐指数
1
解决办法
2968
查看次数

标签 统计

css ×1

html ×1

pyscript ×1

python ×1