python3 repl_Python REPL等

python3 repl

Creating a Python file is pretty easy. Open a new file in your favorite text editor, put some Python code in it, and save it with a .py extension. Done!

创建Python文件非常简单。 在您喜欢的文本编辑器中打开一个新文件,在其中放入一些Python代码,然后以.py扩展名保存。 做完了!

“Done” means “but wait, there’s more!”

“完成”的意思是“但是等等,还有更多!”

RIP

RIP

Let’s try creating a simple Python file. Save the following code as two.py:

让我们尝试创建一个简单的Python文件。 将以下代码另存为two.py:


1 + 1

Since we’re working with a file now, let’s use the python command to run the file instead of opening the REPL:

由于我们现在正在处理文件,因此让我们使用python命令运行文件,而不是打开REPL:


$
$

Pikachu used Python! It’s not very effective…Why don’t we see a “2” anywhere?

皮卡丘用过Python! 它不是很有效……为什么我们在任何地方都看不到“ 2”?

Unlike the REPL, running code in files with Python requires you to explicitly print anything you want to see in the output. The code was executed, but the result vanished into thin air. Let’s try again, this time printing out the result of the addition explicitly:

与REPL不同,使用Python在文件中运行代码要求您显式打印要在输出中看到的任何内容。 代码已执行,但结果消失了。 让我们再试一次,这一次明确地打印出添加结果:


print(1 + 1)

When we run the file this time, we see:

这次运行文件时,我们看到:

翻译自: https://www.pybloggers.com/2016/06/the-python-repl-and-more/

python3 repl

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值