摘要: 1.dict1=dict((['x',1],['y',2])):dict()创建字典 2.dict1={}.fromkeys(('x','y'),-1):fromkeys()创建一个默认字典,字典中元素具有相同的值 3.dict1.keys():获取字典的键值列表 4.dict1.has_key(' 阅读全文
posted @ 2017-10-31 12:51 Rubick7 阅读(872) 评论(0) 推荐(0)
摘要: 1,列表推到式: 对于简单的函数方法,尽量使用表推导式来代替map和filter函数,因为这样往往可以少些很多函数。 例如, nums= [1, 2, 3] squares = map(lambda x: x**2, nums) #使用map squares = [x**2 for x in tes 阅读全文
posted @ 2017-10-31 12:49 Rubick7 阅读(451) 评论(0) 推荐(0)