终端中的Python(如何在定义函数时跳到第二行)

-3 投票
1 回答
1102 浏览
提问于 2025-04-28 09:30

我刚开始学Python,遇到一个问题。当我在终端(mac)里定义一个函数,想写第二行代码时,我按下回车键,结果代码就执行了,而不是换到第二行,显示这个符号(...)。

>>> def test():

... print "this a test"

File "<stdin>", line 2

 print "this a test"
        ^
IndentationError: expected an indented block
>>> 

我该按哪个键呢 ...!?抱歉,我知道这个问题很简单,但这确实是我遇到的困扰。

暂无标签

1 个回答

-1

你需要在第二行按一下Tab键。

>>> def test():
...     print "this is a test"
...
>>>

撰写回答