【问题标题】:Python in Terminal ( How to go to the second line in define Function )终端中的 Python(如何转到定义函数的第二行)
【发布时间】:2014-12-14 13:30:35
【问题描述】:

我是 Python 新手,我的问题是当我想在终端 (mac) 的定义函数中编写第二行时,然后我按 Enter 但它会运行而不是使用此符号 (...) 转到第二行

>>> def test():

... print "this a test"

File "<stdin>", line 2

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

我必须按哪个键...!? 抱歉,我知道这是个很愚蠢的问题,但这是我的问题。

【问题讨论】:

  • 制表符?空格键?应该有大量的教程描述如何使用命令行 python。

标签: python function python-2.7 terminal user-defined-functions


【解决方案1】:

你需要在第二行按tab键。

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

【讨论】:

  • 或空格(我在python shell中使用两个空格,在文件中的代码中使用4个)
猜你喜欢
  • 2022-01-16
  • 1970-01-01
  • 2020-04-14
  • 1970-01-01
  • 2016-05-02
  • 2018-09-09
  • 1970-01-01
  • 1970-01-01
  • 2022-01-06
相关资源
最近更新 更多