首页 > 编程语言 > 详细

【python之路3】if 语句

时间:2017-01-06 01:30:17      阅读:243      评论:0      收藏:0      [点我收藏+]

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‘

  

 

【python之路3】if 语句

原文:http://www.cnblogs.com/sunshuhai/p/6254542.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!