When python refers to the getpass module, there is no response after entering the password and pressing Enter. It is executed in the pycharm software, but it is OK in the IDE that comes with python.
phpcn_u1582
phpcn_u1582 2017-06-14 10:51:39
0
2
1233

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!

phpcn_u1582
phpcn_u1582

reply all(2)
Peter_Zhu

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template