geekdoc-python-zh/docs/pythonland/03.md

89 lines
4.7 KiB
Markdown
Raw Permalink Normal View History

2024-03-03 22:54:39 +08:00
# 在线 Python 解释器:在浏览器中运行 Python
> 原文:[https://python.land/installing-python/python-in-the-browser](https://python.land/installing-python/python-in-the-browser)
就像现在的任何事情一样,你也可以在浏览器中运行 Python。在这个页面上你可以使用我的在线 Python 解释器。它允许您输入 Python 代码,运行它,并查看结果。所有这些都不需要[安装 Python](https://python.land/installing-python) 并自己启动一个 [Python REPL](https://python.land/introduction-to-python/the-repl) 。你可以使用这个在线 Python 解释器来学习 [Python 初学者教程](https://python.land/python-tutorial)。
目录
* [在浏览器中运行 Python](#Running_Python_in_the_browser "Running Python in the browser")
* [在线 Python 解释器](#The_online_Python_interpreter "The online Python interpreter")
* [不是 REPL](#Not_a_REPL "Not a REPL")
* [资源限制](#Resource_limits "Resource limits")
* [使用在线 Python 解释器中的模块](#Using_modules_in_the_online_Python_interpreter "Using modules in the online Python interpreter")
* [疑问?](#Questions "Questions?")
## 在浏览器中运行 Python
简言之,如果您:
* (还)不想安装 Python
* 想要快速开始,
* 首先想试试 Python 是否适合你,在安装之前,
你很幸运!不需要安装任何东西就可以马上上手。
请注意:
* 这是一个测试产品
* 这个在线 Python 解释器故意限制了资源(详见下文)
* 这不是 REPL也不是互动的。不能用`input()`。更多信息见下文。
说了这么多,**实验学习**应该够了。既然你是第一批用户之一,我很想听听你的[评论和问题](https://python.land/contact)(或者咆哮)。
在浏览器中使用 Python 对于学习和探索来说是很好的。然而,如果你开始认真对待 Python 开发,你会发现,在某些时候,你会想要一个合适的 [IDE(集成开发环境)](https://python.land/creating-python-programs/using-a-python-ide)和 Python 的本地安装。如果可以的话我推荐你在 PC 上安装 Python 它将提供更好的体验,并且允许你离线工作。前往我们的 [Python 安装指南](https://python.land/installing-python),学习如何在你的电脑上安装 Python。
## 在线 Python 解释器
[https://crumb.sh/embed/F65R4QZRHmo](https://crumb.sh/embed/F65R4QZRHmo)
这是一个在线 Python 解释器。试试看!
Thank you for reading my tutorials. I write these in my free time, and it requires a lot of time and effort. I use ads to keep writing these *free* articles, I hope you understand! **Support me by disabling your adblocker on my website** or, alternatively, **[buy me some coffee](https://www.buymeacoffee.com/pythonland)**. It's much appreciated and allows me to keep working on this site!
## 不是 REPL
请注意,这不是一个 REPL 或交互式终端。在这个游戏中,您[创建一个真实的 Python 文件](https://python.land/creating-python-programs) (playground.py),您在 Python Land 的真实计算机上执行该文件。所以如果你想看到输出,你需要使用 print 语句来打印它。这里有几个例子可以帮助你开始:
```py
print(1 + 3)
# will print 4
print('Hello world')
# will print 'Hello world'
a = 6 + 9
print(a)
# will print 15
```
## 资源限制
在我们的教程中使用这个在线 Python 解释器时,您不应该遇到资源限制。如果有,可能是由于以下限制之一造成的:
* 输入的大小,
* 程序的运行时间,
* 内存使用情况,
* 流程分叉的数量
* 网络不起作用
## 使用在线 Python 解释器中的模块
你可以用这个在线 Python 解释器[导入 Python 模块](https://python.land/project-structure/python-modules)。包含在 [Python 标准库](https://docs.python.org/3/library/)中的任何东西都应该是可用的,比如 os 模块、[线程](https://python.land/python-concurrency/python-threads)、[多重处理](https://python.land/python-concurrency/python-multiprocessing)、 [JSON](https://python.land/data-processing/working-with-json) 模块、CSV 等等。
但是,您不能安装需要您使用 [pip install](https://python.land/virtual-environments/installing-packages-with-pip) 的外部软件包。我确实安装了一些最常用的模块,尤其是本教程中提到的那些。您可能会看到以下软件包:
* Numpyscipy交响乐
* 皮亚米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅米雅
* 熊猫
* jmespath
* python date util
* pytest(测试)
## 疑问?
如果您有任何问题或意见,请在这里[联系我](https://python.land/contact)。