我创建了以下名为Python的脚本week1_1.py:
import sys
input = sys.stdin.read()
tokens = input.split()
a = int(tokens[0])
b = int(tokens[1])
print(a + b)
但是,当我从Jupyter Notebook中调用它时,出现以下异常:
%run -i week1_1 2 3
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
D:\Mint_ns\week1_1.py in <module>()
8 input = sys.stdin.read()
9 tokens = input.split()
---> 10 a = int(tokens[0])
11 b = int(tokens[1])
12 print(a + b)
IndexError: list index out of range
造成此异常的原因可能是什么?
胡子哥哥
慕姐8265434
相关分类