1、合并两个字典
merged_dic = {key:value for (key,value) in (dic1.items() + dic2.items())}
2、使用map/reduce,将一个str转化成int
def char2num(s):
return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s]
print reduce(lambda x,y:x * 10 + y, map(char2num, '13579'))
3、使用至少两种方式,生成list[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
列表生成器
[x * x for x in range(1, 11)]map
map(lambda x:x*x,range(1,11))- 遍历
4、用一条SQL 语句 查询出每门课都大于80 分的学生姓名
name kecheng fenshu
张三 语文 81
张三 数学 75
李四 语文 76
李四 数学 90
王五 语文 81
王五 数学 100
王五 英语 90
select distinct name from table where name not in (select distinct name from table where fenshu<=80)
select name from table group by name having min(fenshu)>80