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

fromkeys

时间:2019-08-05 20:22:10      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:int   nbsp   class   返回   col   添加   迭代   span   key   

fromkeys会返回新的字典与原字典没关系,直接用字典去访问fromkeys不会对字典产生影响的

dic = {}
a = dic.fromkeys("abc",[1,2,3])  #前面的会迭代添加,后面不会
print(a)
<<<<{a: [1, 2, 3], b: [1, 2, 3], c: [1, 2, 3]}

 

fromkeys

标签:int   nbsp   class   返回   col   添加   迭代   span   key   

原文地址:https://www.cnblogs.com/whileke/p/11305176.html

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