gpt4 book ai didi

python - Python代码中的 "In [X]:"和 "Out[Y]:"是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-03 12:39:21 25 4
gpt4 key购买 nike

我是一个新的 Python 用户,我确信这是一个非常基本的问题,但我无法在任何地方找到答案。当人们在网上发布 Python 代码时,它的格式通常如下:

In [1]: # some stuff
Out[1]:
# some more stuff

InOut 和数字是什么?为什么我的 Python 控制台不像那样?

最佳答案

它们不是 Python 代码。他们是IPython prompts ,一种流行的 Python 附加交互式 shell。

在交互式提示符下执行的每一行代码(由 In 表示)都有编号,产生的输出也有编号(由 Out 表示)。然后,您可以指示 IPython 返回这些输入和输出以重新运行代码或重新使用输出。

参见 Input caching system documentation >

IPython offers numbered prompts (In/Out) with input and output caching (also referred to as ‘input history’). All input is saved and can be retrieved as variables (besides the usual arrow key recall), in addition to the %rep magic command that brings a history entry up for editing on the next command line.

关于python - Python代码中的 "In [X]:"和 "Out[Y]:"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28238430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com