def runUser():
x = raw_input("Enter your username:")
y = raw_input("Enter your password :")
users = [x == "aeduun" and y == "1234", x == "paul" and y == "fifty"]
raw_input("")
if x == users[] and y == users[]:#x == "aeduun" and y == "1234":
print "you are now logged in"
elif x == "Mercuryisle" and y == "shrek":
print "Your account has expired..." \
"You will now bw taken back to the login page"
time.sleep(5)
return runUser()
下面是我作为python2.7小型测试项目的一部分编译的代码。在本文中,我试图用密码和用户名的变量列表来伪造一个基本登录名。该函数能够读取变量之间的关系,但包含对不同列表项的引用的错误。 当我启动程序时,只会调用一个无效的用户名(代码不显示)。 我想要一些关于如何初始化列表项的索引的建议,这些索引将作为if语句的一部分读取。你知道吗
运行方式:
还有一个建议,使用
getpass.getpass()
来获取密码,这样可以防止字符回音。你知道吗以明文形式存储密码是不安全的,但是考虑到这一点,我认为使用元组和集合(即
相关问题 更多 >
编程相关推荐