如何在python REPL中編寫多行代碼? :如何在終端中使用python編寫多行代碼?
aircraftdeMacBook-Pro:~ ldl$ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
例如樣品例如:
i = 0
while i < 10:
i += 1
print i
在終端不知道熱到線進料在Python殼:
我測試控制 + 輸入和Shift + 輸入和命令 + 輸入,他們都錯了:
>>> while i < 10:
... print i
File "<stdin>", line 2
print i
^
IndentationError: expected an indented block
它是無效的語法,所以它不會繼續提示你寫下一行。 – zhenguoli
'for'應該是'while'。 – zhenguoli
你爲什麼不在代碼中寫出你之前寫過的例子? –