2013-10-08 46 views
1

我想在我的mac中爲python製作mac地址欺騙器,因爲我發現其他軟件是不必要的先行/難以理解的。首先,我想要一個選擇框詢問你想欺騙什麼設備,但是我無法獲得if else語句的工作。點如果coice是第一個然後輸入這個值elif的選擇是第二個輸入的值。如果以上都不是,你做錯了什麼。我正在運行python 2.7(Python 2.7)easygui.choicebox如果其他語句如何

TlDr;如果其他語句不工作,我想(python 2.7)。

下面是代碼:

#_._# Mac Changer #_._# 
import easygui 


msg = "What Device do you want to spoof you're mac addresse?" 
title = "SpoofMyMac" 
choices = ["en0 (Ethernet)", "en1 (WiFi)"] 
choice = easygui.choicebox(msg, title, choices) 

##################################### 
if choice == choice[0]:    # 
    easygui.msgbox("Ethernet")  # 
elif choice == choice[1]:   # This is where the problem seems to be. 
    easygui.msgbox("Wifi")   # 
else:        # 
    easygui.msgbox("chus somthin!") # 
##################################### 

現在,這是代碼,任何人都關心的只是開始時幫我這個如果else語句?

提前謝謝! :)

回答

3

從我所看到的,你只是有一個錯字。你想索引choices,而不是choice

if choice == choices[0]: 
    #index choices^   
    easygui.msgbox("Ethernet")  
elif choice == choices[1]: 
    #index choices^   
    easygui.msgbox("Wifi")   
else:        
    easygui.msgbox("chus somthin!") 
+0

非常感謝! :)我愚蠢的錯誤。 :P –