# -*- coding: gb2312 -*- """ Created on Tue Sep 29 23:12:01 2015 @author: Administrator """ """列表推导和字典推导 求偶数数组 numbers=[1,2,3,4,5,6] even = [i for i in numbers if i%2==0] print "列表中的偶数列表:",even even1 = [i*2 for i in numbers] print "列表中的元素*2:",even1 """ """链式比较 a=7 if 1< a< 10: print "判断一个值是否在一定范围内:if i<a<10" """ """for...else 语法 num = [1,2,3,4,5,-1] for i in num: if i<0: break print i else: print "列表数据都为正数" """ """集合操作 a = {1,2,3,4} b = {4,5,6,7} print "a|b",a|b print "a&b",a&b """