如何在我的python程序中创建一个密码以显示为星号

时间:2017-08-31 13:13:30

标签: python

def logInOkay():
  print("You must login before proceeding")
  userId = input("User ID")
  userPw = input("Password")
  if (userId=="Mr Leeman") and (userPw=="Treeroad!"):
    return True
  else:
    print("Error in userId or password")
    return False

我需要能够输入(treeroad!),但需要将其隐藏并替换为星号。

1 个答案:

答案 0 :(得分:0)

您需要使用getch()而不是input()。

请参阅this帖子上的答案。