【发布时间】:2018-07-27 05:02:15
【问题描述】:
我有一个从 Jupyter Notebook 运行的简单 Python 脚本。但是,我传递给它的参数似乎被忽略了,这会导致异常:
two_digits.py
import sys
input = sys.stdin.read()
tokens = input.split()
a = int(tokens[0])
b = int(tokens[1])
print(a + b)
%run two_digits 3 5
ndexError Traceback (most recent call last)
D:\Mint_ns\two_digits.py in <module>()
5 tokens = input.split()
6
----> 7 a = int(tokens[0])
8
9 b = int(tokens[1])
IndexError: list index out of range
【问题讨论】:
标签: python python-3.x jupyter-notebook jupyter