例子

# #循环所有的奇数双数
# a = 1
# while a < 101:
# if a % 2 == 0:
# print(a)
# a += 1
#
# #循环1-100所有的偶数单数
# a = 1
# while a < 100:
# if a % 2 == 1:
# print(a)
# a += 1
#
# #循环1-10
# a = 1
# while a < 11:
# print(a)
# a += 1
# #循环1-10没有7
# a = 0
# while a < 10:
# a += 1
# if a == 7:
# continue
# print(a)
#
# a = 1
# while True:
# if a == 7:
# a += 1
# continue
# elif a == 11:
# break
# print(a)
# a += 1

# name = input("请输入你的名字")
# age = int(input("请输入你的年龄"))
# job = input("请输入你的工作")
# hobbie = input("请输入你的爱好")
# a = '''
# -----------欢迎登录 %s ------------
# name = %s
# age = %d
# job = %s
# hobbie = %s
# --------------end--------------------
# '''%(name,name,age,job,hobbie)
# print(a)

#用户登录且能登录三次
# a = 0
# while a < 3:
# a += 1
# s = input("请输入你的账号")
# d = input("请输入你的密码")
# if s == "123" and d == "456":
# print("登录成功")
# break
# else:
# print("登录失败")
# continue
#用户登录且只要愿意就能一直登录
# username = "congcong"
# password = "123"
# i = 0
# while i < 3:
# name = input("请输入你的用户名")
# pwd = input("请输入你的密码")
# if username == name and password == pwd:
# print('您登录成功')
# break
# else:
# print("登录失败,您还有%d次机会"%(2-i))
# if (2-i) == 0:
# result = input("是否还想再试试?Yes ")
# if result == "Yes":
# i = 0
# continue
# i += 1
# else:print("呵呵")

posted on 2017-10-22 16:43  申聪聪  阅读(112)  评论(0)    收藏  举报

导航