如何在ipython中编写多个语句?

时间:2018-11-01 17:11:41

标签: ipython

我正在尝试遍历列表,并用ipython打印数字和字母:

tuples = [(1, 'a'), (2, 'b'), (3, 'c')]

for number, letter in tuples:
    print(number)
    print(letter)

但是当我在ipython中尝试它时,它只能让我写第一个语句,然后返回输出:

In [34]: tuples = [(1, 'a'), (2, 'b'), (3, 'c')]

In [35]: for number, letter in tuples:
    ...:     print(number)
1
2
3

如何在解释整个块之前添加另一条语句?

0 个答案:

没有答案