标签:password open logs gif error 重试 输出 display for
#!/usr/bin/env python #-*- encoding:utf-8 -*- n = 1 while n <= 10: if n == 7: pass #换成continue不行,因为会跳过本次循环,n不能+1,n永远==7,永远跳过本次循环。 else: print(n) n += 1 # print(‘wss‘,n)
#!/usr/bin/env python #-*- encoding:utf-8 -*- n = 0 while n <= 9: n += 1 if n == 7: pass # 换成continue可以,因为虽然跳出了本次循环,但是下次循环的时候n可以+1 else: print(n)
#!/usr/bin/env python #-*- encoding:utf-8 -*- n = 0;s = 0 #s是之前所有数的总和 while n <= 99: n += 1 s += n # print(s) #输出每次循环的总和 print(s) #输出最后的总和
#!/usr/bin/env python #-*- encoding:utf-8 -*- s = 0 for n in range(1,101): # print(n) s += n print(s)
#!/usr/bin/env python #-*- encoding:utf-8 -*- n = 0 while n <= 99: n += 1 if n % 2 == 1: print(n)
#!/usr/bin/env python #-*- encoding:utf-8 -*- for n in range(1,101,2): print(n)
#!/usr/bin/env python #-*- encoding:utf-8 -*- n = 0 while n <= 99: n += 1 if n % 2 == 0: print(n)
#!/usr/bin/env python #-*- encoding:utf-8 -*- for n in range(2,101,2): print(n)
#!/usr/bin/env python #-*- encoding:utf-8 -*- n = 0;s = 0 while n <= 98: n += 1 if n % 2 == 0: s -= n else: s += n # print(s) #输出每次循环运算的结果 print(s) #输出最后的运算结果
#!/usr/bin/env python #-*- encoding:utf-8 -*- s = 0 for n in range(1,100): # print(n) if n % 2 == 0: s -= n else: s += n print(s)
#!/usr/bin/env python # -*- encoding: utf8 -*- import getpass count = 0 while count < 3: user = input(‘请输入用户名:‘) pwd = getpass.getpass(‘请输入密码:‘) if user == ‘wss‘ and pwd == ‘123‘: print(‘欢迎登陆‘) print(‘..........‘) break else: print(‘用户名或者密码错误‘) count += 1
#!/usr/bin/env python #-*- encoding:utf-8 -*- import getpass username = ‘wss‘ password = ‘123‘ flag = 0 def login(): user = input(‘username:‘) passwd = getpass.getpass(‘password:‘) return user,password while flag<3: user,passwd = login() if username == user and password == passwd: print(‘hello,jason‘) break else: flag += 1 print (‘error,input again‘)
标签:password open logs gif error 重试 输出 display for
原文地址:http://www.cnblogs.com/wushuaishuai/p/7742503.html