1、if语句用法(if....else....)
#!/usr/bin/env python # -*- coding:utf-8 -*- my_name = raw_input("please put username:") my_pass = raw_input("please put password:") if my_name == "abc" and my_pass == '123': print '登陆成功!' else: print '登陆失败!'
2、if.....elif.....elif......else
#!/usr/bin/env python # -*- coding:utf-8 -*- st = raw_input("please enter a number:") if st == '1': print 'you enter num1' elif st == '2': print 'you enter num2' elif st == '3': print 'you enter num3' else: print 'you enter a unkown num'