使用getpass模块
#!/usr/bin/env pythonimport getpassusername = raw_input("username:")password = getpass.getpass("password:") #第一个getpass是模块名,第二个getpass是模块里面的函数if username == 'bob' and password == '123456':print 'Login successful'else:print 'Login incorrect'