1 2 3 4

【python之路3】if 语句

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'

  

 

posted @ 2017-01-06 00:03  I我的博客I  阅读(627)  评论(0编辑  收藏  举报