python之三-statements and functions
来源:互联网 发布:麦当劳改名知乎 编辑:程序博客网 时间:2024/05/22 06:39
1.if
if condiction1 and condition2:
action1
elif condition3:
action2
else:
action3
<,<=,>,>=,==,!=,in
x=2;y=3;L=[0,1,2]
if (1<x<=3 and 4>y>=2) or (1==1or o!=1) or 1 in L:
print 'Hello world'
2.while
while x<=4:
...
3.for
for item i in set s :
...
for i in range(1,7):
...
4.functions
可以有多个return
5.multiple assignment
x,y=2,3
5.help info for functions
6.Scope Rules
Build-in(Python)
predefined names(len,open,execfile,etc.) and types
Global(module)
Names assigned at the top level of a module, or directly in the interpreter
Names declared global in a function
Local(function)
Names assigned inside a function definition or loop
7.exception handling
类似于java
try:
except IOError:
finally:
def factorial(n)
if n<0
raise ValueError,"Expected non-negative number"
.....
8.File Objects
file.open()
file.read()
file.write()
file.readlines
file.readline
- python之三-statements and functions
- Using Functions SYSFUNC and IFC to Conditionally Execute Statements in Open Code
- Python 入门教程 11 ---- Lists and Functions
- [Python]Functions, Variables, and the Call Stack
- Decorators ,Lambda Functions and Sequences of Python
- Beginning Python - Chapter5 : conditinals,loops,and some other statements
- Learning with python: Chapter2 Variables, expressions and statements
- Can functions be defined below return statements
- 【JDBC4.2】三、Statements
- Learning with python: Chapter3~4 Functions,Conditionals and Recursion
- 4.1 - Python Statements
- Think Python:Chapter 2:Variables(变量), expressions(表达式) and statements(陈述) 的笔记
- Statements and Declarations in Expressions
- JDBC - Statements, PreparedStatement and CallableStatement
- Stored Procedures and Functions
- URL functions and classes
- jquery selectors and functions
- JQuery Callback and Functions
- Java观察者模式
- 《C++ Primer第五版》读书笔记(1)--redhat linux下安装gcc 4.8.2
- Android点亮屏幕和解锁完整示例
- Android API之android.view.View.MeasureSpec
- 在myEclipse中进行Debug调试
- python之三-statements and functions
- jQuery中Ajax-ajax方法
- c++中的floor,ceil,round
- XCode Debugger中的Icon符号的意义
- 集合使用NSArray、NSSet、NSDictionary的使用
- Mybatis 之 resultMap简介
- 编码规范
- Vijos 1059
- zoj 3264 Present for MM (坑题,写博客只是不想更多人被坑)