1, python references the getpass module and there is no response after entering the password and pressing Enter
2,
#!/usr/bin/env python3.5
#用戶登錄
import getpass
i = 1
user = 'eason'
pwd = 'eason123'
while True:
i1 = input('請輸入賬號:')
p1 = getpass.getpass('請輸入密碼:')
if i1 == 'user' and p1 == 'pwd':
print('login sucessful')
break
else:
print('login failer')
if i == 3:
break
i = i + 1
3. It is possible to use the IDE that comes with python, but this problem occurs when Pycharm is executed. Thanks!
getpass uses msvcrt.getch
to read the keystrokes, which is invalid in the IDE.
The original poster’s code: p1 == 'pwd', not 'p1 == pwd'.
if i1 == 'user' and p1 == 'pwd':
print('login sucessful')
break