码迷,mamicode.com
首页 > 其他好文 > 详细

other

时间:2017-03-20 15:18:15      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:rabl   size   列表   ==   print   ems   range   for   元素   

1.两个列表变成键值对关系

    

list1 = [‘name‘,‘sex‘,‘address‘,‘age‘]
list2 = [‘huahua‘,‘boy‘,‘chengdu‘,23]
dict1={}
for i in range(0,len(list1)):
for j in range(0,len(list2)):
if i == j:
dict1[list1[i]] = list2[j]

print(dict1)


2.map

遍历序列,对序列中每个元素进行操作,最终获取新的序列
map(func, *iterables) --> map object
new_map = map(lambda a: a + 100, range(10))
new_enum = enumerate(new_map,1)
new_dic = dict(new_enum)
print(new_dic.items())

  

other

标签:rabl   size   列表   ==   print   ems   range   for   元素   

原文地址:http://www.cnblogs.com/lovuever/p/6589168.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!