python --if语句
2015-12-04 08:10
507 查看
if语句之后的冒号
以四个空格的缩进来表示隶属关系, Python中不能随意缩进
if <条件1>:
statement
elif <条件2>:
statement
elif <条件3>:
statement
else:
statement
以四个空格的缩进来表示隶属关系, Python中不能随意缩进
if <条件1>:
statement
elif <条件2>:
statement
elif <条件3>:
statement
else:
statement
i = 1 if i > 0: print 'positive i' i = i + 1 elif i == 0: print 'i is 0' i = i * 10 else: print 'negative i' i = i - 1 print 'new i:',i
相关文章推荐
- 学习Python (九)
- 饿了么黑客马拉松参赛杂谈
- python核心编程-默认函数对象参数
- python 爬取天气温度
- python 爬取贴吧图片
- python操作excel的技巧整理
- python解析XML方法
- Conque ERROR: Python interface cannot be loaded
- Python.h: No such file or directory
- Python结构化编程
- python requests 高级用法 -- 包括SSL 证书错误的解决方案
- python execl转xml应用
- 使用Python开发windows GUI程序入门实例
- Python脚本自动化编译RPM包
- Python之路(二)
- 17.2. socket — Low-level networking interface Python
- python 中 类, 模块, 包的组织
- 趣学Python-教孩子学编程--第十二章
- 利用python中的pandas,sklearn进行数据挖掘 basic_of_datamining
- Python扩展库psutil用法精要