Car*_*ett 0 input raw-input python-3.x python-3.6
e=input('what's your name?')
print('so you %s, %s, %s.' % (e,l,x))
Run Code Online (Sandbox Code Playgroud)
我想创建一个程序,我需要在其中回答我的问题,但使用 input() 只会返回[so you , , .].
好的,我猜你说的是 Python 3.6。
第一个错误:
e=input('what's your name?') #notice how you're using too many "'"
Run Code Online (Sandbox Code Playgroud)
正确的:
e=input("what's your name?")
Run Code Online (Sandbox Code Playgroud)
第二个错误:
print('so you %s, %s, %s.' % (e,l,x))
#you did not specify l and x, so Python will throw an error
Run Code Online (Sandbox Code Playgroud)
正确的:
在使用“l”和“x”变量之前,对其进行声明和赋值。
只需像对“e”一样输入,例如:
l=input("what's your L?")
Run Code Online (Sandbox Code Playgroud)
raw_inputs,因为所有输入都是raw_inputs。input因为它太有问题了。所以 Python 的 3 input== Python 的 2 raw_input。
要input在 Python 3 中使用 Python 的 2 正则,请使用eval(input()). 有关更多信息,请参阅:http : //docs.python.org/dev/py3k/whatsnew/3.0.html