37,742
社区成员
发帖
与我相关
我的任务
分享
username = input()
password = input()
if username == 'Kate' and password == 666666:
print('登录成功!')
password = input()
改为:
passwordStr = input()
password = int(passwordStr)
但其实更推荐你改为,见名知意的,加上变量类型的写法,比如:
usernameStr = input("请输入用户名")
passwordStr = input("请输入密码")
if usernameStr == 'Kate' and passwordStr == '666666':
print('登录成功!')
或:
usernameStr = input("请输入用户名")
passwordStr = input("请输入密码")
passwordInt = int(passwordStr)
if usernameStr == 'Kate' and passwordInt == 666666:
print('登录成功!')
详见:
input返回值是字符串 · Python新手小白常见错误和问题
username = input()
password = input()
if username == 'Kate' and password == '666666':
print('登录成功!')
print(type(username),type(password),type(666666),type('666666'))#这行可以帮助你理解
username = input()
password = int(input())
if username == 'Kate' and password == 666666:
print('登录成功!')