Python输入输出及循环
- input 输入
- print 输出
- for 循环
for x in range(0,6): if x<3: print("\nx:",x) else: continue print("\nhello")
4. while 循环
print("欢迎登录,请输入您的帐号及密码(3次机会):\n") name = "王强" pwd = "123" i = 0 #计数器 while i<3: username = input("\n账号:") userpwd = input("\n密码:") if username == name: if userpwd == pwd: print("\n——登录成功——") break else: print("\n*密码错误*") else: print("\n*账号错误*") i+=1 else: print("\n\t\t*\t*\t*\t请明天再来\t*\t*\t*")
- break:跳出循环;
- continue:跳出本次循环;