一行输入3个数字
Input 3 number in one line
我们可以这样从用户那里得到3个号码
a = int(input())
b = int(input())
c = int(input())
现在如何在一行中从用户那里获取 3 个号码?
a , b , c = int(input())
我试过了,但不行
你可以这样做:
a, b, c = input("Insert the 3 values: ").split()
print(f"a: {a}\nb: {b}\nc: {c}")
有关详细信息,请参阅 类似问题
试试这个:
a , b , c = map(int,(input().split()))
try:
a,b,c = map(int,input('input').split())
print(a,b,c)
except:
print('input is no good')
如果您正在从 .txt
文件中读取数据并且希望在一行中映射变量 a、b 和 c。
示例:
inputFile = open("example.txt",r)
a, b = map(int, inputFile.readline().split())
我们可以这样从用户那里得到3个号码
a = int(input())
b = int(input())
c = int(input())
现在如何在一行中从用户那里获取 3 个号码?
a , b , c = int(input())
我试过了,但不行
你可以这样做:
a, b, c = input("Insert the 3 values: ").split()
print(f"a: {a}\nb: {b}\nc: {c}")
有关详细信息,请参阅
试试这个:
a , b , c = map(int,(input().split()))
try:
a,b,c = map(int,input('input').split())
print(a,b,c)
except:
print('input is no good')
如果您正在从 .txt
文件中读取数据并且希望在一行中映射变量 a、b 和 c。
示例:
inputFile = open("example.txt",r)
a, b = map(int, inputFile.readline().split())