我是Python的初学者,我试图在一个简单的编程竞赛问题中读取两个数字。在# Codeforces New Year 2013 Contest;
# http://codeforces.com/contest/379/problem/A
import sys;
def main ():
a = input ();
b = input ();
resto = 0;
result = 0;
while (a > 0):
a-=1
result += 1;
resto += 1;
if (resto >= b):
resto -= b;
a += 1;
print result;
main ();
如果我试图用4 2(用空格隔开)运行程序,会出现以下错误:ValueError: invalid literal for int() with base 10: '4 2'
但如果我输入4[enter],然后输入2[enter],程序运行时不会出现任何问题。在
我如何从Python中读取STDIN,就像C++一样?在
编辑:很抱歉搞砸了!我通常以这种方式运行输入代码:
C++://&检验<
Python:Python主.py<;测试