【Python】】对于input函数直接对两个字符串赋值的试验

1、第一次试验

s , t = input()

print('{0},{1}'.format(s,t))

#对于上述代码,输入1,2会发生错误

#发生ValueError: too many values to unpack (expected 2)这种错误

2、第二次试验

s , t = eval(input())

print('{0},{1}'.format(s,t))

#对于上述代码,输入1,2是可以执行的

#但是因为eval的原因输入字符串会出现NameError: name '我' is not defined这种错误

3、第三次试验

s = input()

t = input()

print('{0},{1}'.format(s,t))

#这个是对字符串与数字是完美运行

#这说明了什么问题?

结论:input函数不能同时把两个字符串赋值到两个变量中

原文地址:https://www.cnblogs.com/naraka/p/8855257.html