条件语句格式为if...elif...else
逻辑与或非分别为and,or,not
其它条件语句还有is,not
可以直接if 0<a<100
for循环
遍历内容
a=[1,2,3,4,5] for item in a: print item
遍历索引
for index in len(a): print a[index]
索引+内容, enumerate
for index, item in enumerate(a): print index, item
zip. 如果a和b想一起循环
for item1,item2 in zip(a,b): print item1,item2
当a和b短的那个循环完,则终止
for:
#循环内容
else:
正常退出for,则执行
n=37 for i in range(2,n/2): if n%i == 0: print '是合数' break else: print '是素数'