首页 > 代码库 > 流程判断(if...else)
流程判断(if...else)
当用户输入密码时候,如果输入正确会输出welcom user login,如果输入错误会输出invalid username or password
#!/usr/bin/env python # -*- coding:utf-8 -*- import getpass _username = "xcn" _password = "admin" username = input("username:") password = getpass.getpass("password:") print(username, password) if _username == username and _password == password: print("welcome user {name} login ..." .format(name=username)) else: print("invalid username or password!") ce
#!/usr/bin/env python # -*- coding:utf-8 -*- age_of_xcn = 20 guess_age = int(input("guess age:")) if guess_age == age_of_xcn: print("yes,you got it") elif guess_age > age_of_xcn: print("think smaller") else: print("think bigger") 执行结果: guess age:12 think bigger guess age:22 think smaller
本文出自 “小菜鸟” 博客,请务必保留此出处http://baishuchao.blog.51cto.com/12918589/1932908
流程判断(if...else)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。