我一直在嘗試一段時間才能訪問我最近返回的值,並在if語句中使用它,而不必調用該值。訪問以前返回的值 - Python3.2
基本上我有一個while循環調用一個函數,允許用戶輸入,然後將輸入返回到循環中。
while selection() != 0: ## Calls the "WHAT WOULD YOU LIKE TO DO" list and if it is 0 quits the script
input() ## just so it doesn't go straight away
if selection.return == 1: ## This is what I would like to happen but not sure how to do it... I've googled around a bit and checked python docs
見,如果我把:
if selection() == 1:
它會工作,但再次顯示「你會喜歡做的事」的文字...
對不起,如果這是一個明顯的解決方案,但幫助將非常感謝:)
你必須使用一個變量。所以,雖然真:sel = selection();如果sel == 0:break;否則:#做任何你做的事 – AdamKG 2012-01-13 19:41:05