如何在pyscript.js中实现Python代码在浏览器端的运行?

2026-06-09 09:313阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计295个文字,预计阅读时间需要2分钟。

如何在pyscript.js中实现Python代码在浏览器端的运行?

PyScript 是一个框架,让用户能在浏览器中用 HTML 接口创建丰富的 Python 应用。PyScript 致力于提供一种具有一致风格规则、更易表达的高级编程语言。


PyScript is a framework that allows users to create rich Python applications in the browser using HTML’s interface. PyScript aims to give users a first-class programming language that has consistent styling rules, is more expressive, and is easier to learn.(摘自pyscript.net)

PyScript是一个允许用户使用HTML界面在浏览器中创建丰富Python应用程序的框架。PyScript旨在为用户提供一种一流的编程语言,该语言具有一致的样式规则、更具表现力、更易于学习。(-- 百度翻译)

文档:

  • ​​pyscript.net/​​
  • ​​github.com/pyscript/pyscript/blob/main/GETTING-STARTED.md​​
  • ​​github.com/pyscript/pyscript​​

代码示例

如何在pyscript.js中实现Python代码在浏览器端的运行?

<html>

<head>
<link rel="stylesheet"
href="pyscript.net/alpha/pyscript.css" />
<script defer
src="pyscript.net/alpha/pyscript.js"></script>
</head>

<body>
<py-script>
from datetime import datetime

now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(now)
print('Hello, World!')
</py-script>
</body>

</html>

页面输出结果

2022-05-07 09:57:04
Hello, World!



本文共计295个文字,预计阅读时间需要2分钟。

如何在pyscript.js中实现Python代码在浏览器端的运行?

PyScript 是一个框架,让用户能在浏览器中用 HTML 接口创建丰富的 Python 应用。PyScript 致力于提供一种具有一致风格规则、更易表达的高级编程语言。


PyScript is a framework that allows users to create rich Python applications in the browser using HTML’s interface. PyScript aims to give users a first-class programming language that has consistent styling rules, is more expressive, and is easier to learn.(摘自pyscript.net)

PyScript是一个允许用户使用HTML界面在浏览器中创建丰富Python应用程序的框架。PyScript旨在为用户提供一种一流的编程语言,该语言具有一致的样式规则、更具表现力、更易于学习。(-- 百度翻译)

文档:

  • ​​pyscript.net/​​
  • ​​github.com/pyscript/pyscript/blob/main/GETTING-STARTED.md​​
  • ​​github.com/pyscript/pyscript​​

代码示例

如何在pyscript.js中实现Python代码在浏览器端的运行?

<html>

<head>
<link rel="stylesheet"
href="pyscript.net/alpha/pyscript.css" />
<script defer
src="pyscript.net/alpha/pyscript.js"></script>
</head>

<body>
<py-script>
from datetime import datetime

now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(now)
print('Hello, World!')
</py-script>
</body>

</html>

页面输出结果

2022-05-07 09:57:04
Hello, World!