标签:guess 语句 splay for abc opened print hung enter
if 条件成立:
执行条件成立后的代码
else:
执行条件不成立的代码
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # Author:Hiuhung Wan 4 _username = "Hiuhung Wan" 5 _password = "abcd1234" 6 username = input("Username:") 7 password = input("Password:") 8 if _username == username and _password == password: 9 print("Welcome user {name} login...".format(name = username)) 10 else: 11 print("Invalid username or password!")
if 表达式1:
语句1
elif 表达式2 :
语句2
elif 表达式3 :
语句3
elif 表达式m :
语句m
else:
语句
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # Author:Hiuhung Wan 4 age_of_MrWang = 48 5 guess_age = int(input("Enter the age of Mr Wang:")) 6 if guess_age == age_of_MrWang: 7 print("Yes,you got it!") 8 elif guess_age < age_of_MrWang: 9 print("Think bigger!") 10 else: 11 print("Think smaller!")
标签:guess 语句 splay for abc opened print hung enter
原文地址:http://www.cnblogs.com/hiuhungwan/p/7674359.html