Home  >  Q&A  >  body text

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.

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_u1582phpcn_u15822683 days ago1206

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-06-14 10:53:39

    getpass uses msvcrt.getch to read the keystrokes, which is invalid in the IDE.

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你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

    reply
    0
  • Cancelreply