尝试一下你的意思:user_provided_value = raw_input("Say something:")
if user_provided_value == "v1":
print "Heavier than a duck!"
elif user_provided_value == "v2":
print "Lighter than a duck!"
else:
print "You must enter either v1 or v2"
你说的是(忽略v1和v2变量):('
#2 [ ('
= #3 to be the result of assigning
#5 to a tuple composed of
raw_input() #6 what the user types in at the prompt
, #7 (the comma operator creates a tuple)
('>') #8 And '>'
= # to be
raw_input() #4 what the user types in at the prompt
用易读的英语把这些行打出来,你是说:
“将''的结果。”。
说“将某个固定值设置为等于用户提供的值”等于说“将5设置为等于上一个方程的值”的代数等价物
*由于逗号运算符是绑定最少的运算符之一,您实际上正在将由字符串raw_input(), '>'组成的元组设置为等于第二个raw_input调用中的字符串。
该语句可分为以下几个部分:Set the string '' = raw_input()
raw_input(), '>' = raw_input()解释为:Set the tuple composed of the results of calling raw_input() and '>' to be equal to the results of calling raw_input()