首页 > 代码库 > python控制流程

python控制流程

if..else..结构:

eg1.

# 输入用户名密码,进行校验,并显示校验结果
import getpass _name = "boreas" _pw = "super123" name = input("name:") pw = getpass.getpass("password:") if _name == name and _pw == pw: print("you login on success!") else: print("you login on bad!")
输入正确:
name:boreas
password:
you login on success!
输入错误:
name:zhangsan
password:
you login on bad!

 

python控制流程