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!
天蓬老师2017-06-14 10:53:39
getpass uses msvcrt.getch
to read the keystrokes, which is invalid in the IDE.
扔个三星炸死你2017-06-14 10:53:39
The original poster’s code: p1 == 'pwd', not 'p1 == pwd'.
if i1 == 'user' and p1 == 'pwd':
print('login sucessful')
break