【Python】改編字典中一個key的value值,另一個不相關的key-value值也被改變了。

  報錯代碼簡化版: a = {'k1': {'name': 'name_k1'}, 'k2': {'name': 'name_k2'}} b = dict.fromkeys(a.keys(), {}) for k in a.keys(): print('-------------%s------------------' % k) print(k) prin
相關文章
相關標籤/搜索