所以這是我的代碼,我想隱藏我的密碼,但我不知道如何。我環顧四周,沒有一個似乎適合我的編碼,這是目前的編碼。我的意思是我看過show =「*」,還有getpass,但我不知道如何將它們放入這個編碼中。即時通訊使用Python 2.7.3和即時編碼在樹莓派。python隱藏raw_input
ans = True
while ans:
print("""
-------------
| 1. Shutdown |
| 2. Items |
-------------
""")
ans=raw_input("""
Please Enter A Number: """)
if ans == "1":
exit()
elif ans == "2":
pa=raw_input("""
Please Enter Password: """)
if pa == "zombiekiller":
print("""
----------------
| 1. Pi password |
| 2. Shutdown |
----------------
""")
pe=raw_input ("""
Please Enter A Number: """)
if pe == "1":
print ("""
Pi's Password Is Adminofpi""")
import time
time.sleep(1)
exit()
elif pe == "2":
exit()
else:
print("""
You Have Entered An Inccoredt Option. Terminating Programm""")
import time
time.sleep(1)
exit()
else:
print("""
You Have Entered An Inccorect Password. Terminating Programm""")
import time
time.sleep(1)
exit()
使用[getpass.getpass()](http://docs.python.org/2/library/getpass#getpass.getpass)。 [獲取命令行輸入密碼在Python]的 – falsetru
可能重複(http://stackoverflow.com/questions/9202224/getting-command-line-password-input-in-python) – IanAuld