/* if ....else .... */
[root@localhost test1]# vim .py
//ADD
#!/usr/bin/python if >:
print 'hello python'
print 'TRUE'
else:
print 'FALSE' [root@localhost test1]# python .py
FALSE
/* elif
如果if 不成立
elif 成立,则执行elif 如果if不成立
elif也不成立
则执行else
*/
[root@localhost test1]# vim .py
//ADD
#!/usr/bin/python if >:
print 'hello python'
print 'TRUE'
elif 'a':
print 'b'
else:
print 'FALSE' [root@localhost test1]# python .py
b
[root@localhost test1]# vim .py
//ADD
#!/usr/bin/python if >:
print 'hello python'
print 'TRUE'
elif :
print 'b'
else:
print 'FALSE' [root@localhost test1]# python .py
FALSE
/*     利用 raw_input()输入或输出的是 字符串,

        始终 比整型数值大,所以当设计一个“分数脚本”时,没办法得出正确的结果

        可以利用 int('')这样的形式,将字符串转换为整型。
*/
[root@localhost test1]# vim .py
//ADD
#!/usr/bin/python score = int(raw_input("Please input your score: "))
if score >= :
print 'A'
print 'excellent'
elif score >= :
print 'B'
print 'very good' elif score >=7:
print 'C'
print 'good'
else:
print 'D'
print 'Sorry,you failed.' [root@localhost test1]# python .py
Please input your score:
D
Sorry,you failed.
[root@localhost test1]# python .py
Please input your score:
C
good
[root@localhost test1]# python .py
Please input your score:
A
excellent
[root@localhost test1]# python .py
Please input your score:
B
very good
/* a.lower()  -- 这个lower()函数能够把大写的东西变成小写 */
[root@localhost test1]# vim .py
//ADD
#!/usr/bin/python yn = raw_input("Please input [Yes/No]: ")
yn = yn.lower()
if yn == 'y' or yn == 'yes':
print "programe is running..."
elif yn == 'n' or yn == 'no':
print "programe is exit"
else:
print "please input [Yes/No]" [root@localhost test1]# python .py
Please input [Yes/No]: Yes
programe is running...
[root@localhost test1]# python .py
Please input [Yes/No]: No
programe is exit
[root@localhost test1]# python .py
Please input [Yes/No]: yes
programe is running...
[root@localhost test1]# python .py
Please input [Yes/No]: no
programe is exit
[root@localhost test1]# python .py
Please input [Yes/No]: ddd
please input [Yes/No]

最新文章

  1. 屌丝程序员的梦想 (六) 我也写个开源CMS
  2. python 3 学习笔记 (三)
  3. ReferenceEquals和 == 和equals()的比较
  4. oracle中如何指定表字段自增
  5. boost总结之any
  6. Java基础--说集合框架
  7. 转义字符和ASCII
  8. SMO启发式选择
  9. Java中,当表单含有文件上传时,提交数据的如何读取
  10. POJ 2039 To and Fro
  11. mysql之 mysql 5.6不停机双主一从搭建(活跃双主一从基于日志点复制)
  12. codeM美团编程大赛初赛B轮D题
  13. iOS UIAlertController中加入倒计时,输入框,Swift讲解
  14. Parallel中分区器Partitioner的简单使用
  15. redis学习资料
  16. CentOS 7.3/Linux .net core sdk 安装
  17. 小程序数据绑定点赞效果切换(交流QQ群:604788754)
  18. 使用HttpWebRequest请求API接口以及其他网站资源
  19. Python 标准类库-日期类型之datetime模块
  20. IBM 3650 M3 yum upgrade后系统无法登陆问题

热门文章

  1. [Violet]天使玩偶
  2. [NOIP2015 TG D2T3]运输计划
  3. BZOJ1034 [ZJOI2008]泡泡堂BNB 【贪心】
  4. webpack散记
  5. 【枚举暴力】【UVA11464】 Even Parity
  6. [zabbix]zabbix分区表操作步骤
  7. 美国选举问题/完全背包/Knapsack
  8. 查看oracle日志文件切换频率
  9. sshSSH Secure Shell Client root用户无法登录解决办法
  10. [LeetCode] 14. Longest Common Prefix ☆