免费 · 开发
在线 Python 编译器.
无需安装或注册,直接在浏览器中编写并运行 Python 3 代码:查看输出和错误、为 input() 提供输入、加载示例、下载 .py 并生成分享链接。
Program input (stdin): one line per input() call
Press Run to see the output here.Python 3.14 by Pyodide (MPL-2.0) in WebAssembly. Standard library only (math, json, re, datetime, collections, dataclasses…); packages such as numpy and network access are not available. Stop restarts Python, which clears variables.
在浏览器中运行 Python 代码
- 在 main.py 中输入或粘贴代码,或在
Example中选择一个程序。 - 如果程序调用 input(),请打开
Program input (stdin),每行写一个值。 - 点击
Run (Ctrl+Enter)。输出显示在下方;错误以红色显示,并标出 main.py 中出错的行。 - 程序运行太久时点击
Stop停止,然后用Download .py或Copy share link保存代码。
首次运行会下载一次 Python(约 12 MB),之后浏览器会缓存。代码会保存在此浏览器中,下次回来仍在。
支持与不支持的功能
这是带有标准库的 CPython 3.14:math、random、re、json、csv、datetime、collections、itertools、dataclasses、decimal、fractions、statistics 等。不提供 numpy、pandas 或 requests 等第三方包,也没有网络访问和图形窗口,因此无法显示 turtle 和 tkinter 程序。
Stop 会重启 Python,并清除之前运行留下的变量。如需测试正则表达式,请使用正则表达式测试器;如需用 SQL 探索数据,请使用对 CSV 和 JSON 文件执行 SQL 查询。
限制与支持格式
输入内容在您的设备上处理。
英语技术说明
Python 3.14 standard library only: packages such as numpy or pandas, network access and graphical windows are not available. The first run downloads about 12 MB, then the browser caches it.
Runs CPython 3.14 compiled to WebAssembly by Pyodide (MPL-2.0) in a background worker on your device; your code and its input never leave the browser. Share links store the code inside the link.
The Fibonacci example prints the first 15 numbers and fib(300); the Hello example reads a name from Program input and greets it.
常见问题
我的代码会发送到服务器吗?
不会。Python 以 WebAssembly 形式在浏览器的后台 worker 中运行。分享链接把代码直接保存在链接里。
为什么 input() 不等我输入?
程序在后台运行,它会读取您在 Program input 中写的各行,每次调用 input() 读取一行。读完后 input() 会抛出 EOFError。
可以用 pip 安装包吗?
不可以。只包含标准库,因此工具不会从其他服务器下载任何代码。