什麼是非常簡單的while
循環語句是否會繼續下面的程序,直到用戶鍵入「exit」?簡單while循環直到Python中斷
例如,
while response = (!'exit')
continue file
else
break
print ('Thank you, good bye!')
#I know this is completely wrong, but it's a try!
我至今文件:
#!/usr/bin/python
friends = {'John' : {'phone' : '0401',
'birthday' : '31 July',
'address' : 'UK',
'interests' : ['a', 'b', 'c']},
'Harry' : {'phone' : '0402',
'birthday' : '2 August',
'address' : 'Hungary',
'interests' : ['d', 'e', 'f']}}
response = raw_input("Please enter search criteria, or type 'exit' to exit the program: ").split()
try:
print "%s's %s is %s" % (response[0], response[1], friends[response[0]][response[1]])
except KeyError:
print "Sorry, I don't know about that. Please try again, or type 'exit' to leave the program: "
即我的主要問題是,是否有具體的說法,意思是「繼續運行該文件」 – user1374310