• python中字典的复制


    1、

    >>> test1 = dict(key1="xxx",key2="aaa",key3=100,key="abc")
    >>> test1
    {'key1': 'xxx', 'key2': 'aaa', 'key3': 100, 'key': 'abc'}
    >>> type(test1)
    <class 'dict'>
    >>> len(test1)
    4
    >>> test2={}
    >>> for i,j in test1.items():
        test2[i] = j
    
        
    >>> test2
    {'key1': 'xxx', 'key2': 'aaa', 'key3': 100, 'key': 'abc'}
    >>> test1
    {'key1': 'xxx', 'key2': 'aaa', 'key3': 100, 'key': 'abc'}

    2、

    >>> test1 = {"key1":"aaa","key2":"bbb","key3":"ccc"}
    >>> test1
    {'key1': 'aaa', 'key2': 'bbb', 'key3': 'ccc'}
    >>> test2 = test1.copy()
    >>> test2
    {'key1': 'aaa', 'key2': 'bbb', 'key3': 'ccc'}
  • 相关阅读:
    Oracle基础操作
    Linux的常用命令
    Javascript 上课笔记
    Linux操作指令
    css样式分类
    DW
    标准sql执行顺序
    Mysql数据库
    模拟课----需求文本
    php 发送邮件
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14220478.html
Copyright © 2020-2023  润新知