Python输入输出及循环

  1. input 输入
  2. print 输出
  3. for 循环
    for x in range(0,6):
        if x<3:
            print("
    x:",x)
        else:
            continue
            print("
    hello")

    4. while 循环

print("欢迎登录,请输入您的帐号及密码(3次机会):
")
name = "王强"
pwd = "123"
i = 0  #计数器
while i<3:
    username = input("
账号:")
    userpwd = input("
密码:")
    if username == name:
        if userpwd == pwd:
            print("
——登录成功——")
            break
        else:
            print("
*密码错误*")
    else:
        print("
*账号错误*")
    i+=1
else:
    print("
		*	*	*	请明天再来	*	*	*")
    • break:跳出循环;
    • continue:跳出本次循环;
原文地址:https://www.cnblogs.com/wq-code/p/6631807.html