当前位置:网站首页>dict和set的基本操作
dict和set的基本操作
2022-06-12 23:30:00 【奋斗少年轩】
dict中扩展字典的三种方法
1第一种直接使用key=value

2第二种使用setdefault

3 使用update

二dict中获取所有的key, 获取所有的value, 获取所有的items
keys

values

items

三定义空集合

6set中,求差集,合集,求交集
差集

合集

交集

四 添加一个元素
用 set.add

删除一个元素

五dict和list中copy方法画图加代码解释
list——date1=list——date2 相当于直接赋值 随便改变其中一个都会影响另一个
而list——date3和list——date4是切片复制改变一个不会影响另一个

dict浅拷贝,dict_data1和dict_data2两者是独立的,但是里面的元素指向同一个,所以一个改变后,另一个也会随之而变


dict深拷贝完全拷贝,两者完全独立,即使改变一个,另一个仍保持不变


边栏推荐
- The Milvus graphical management tool Attu is coming!
- Anti aliasing / anti aliasing Technology
- Embedded pipeline out of the box
- Software development tools [3] theoretical basis of software development tools
- CST learning: four element array design of circular patch antenna (III) array formation and parallel excitation
- Is it safe to open an account for flush stock account
- Function introduction and common terms of ZABBIX
- 启牛帮开通的股票账户是安全可信的吗?
- Ten key defensive points in the detailed attack and defense drill
- lua 条件语句
猜你喜欢

RT thread quick start - experience RT thread

Alien skin exposure X7 color filter plug-in, raw post-processing tool
C language: how to give an alias to a global variable?

Insight into China's smart medical industry in 2022

Unprecedented analysis of Milvus source code architecture
![[recommended collection] easy to understand graphic network knowledge - Part 1](/img/5a/dc9f1fd6cfdc1350f757b70e368fe3.png)
[recommended collection] easy to understand graphic network knowledge - Part 1

Redis实现短信验证码登录

ASP. Net core Middleware

ShardingSphere-proxy-5.0.0部署之分表实现(一)

Zhengzhou University of light industry -- development and sharing of harmonyos pet health system
随机推荐
CS for mobile security [nethunter]
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
Gb28181 protocol -- alarm
人脸检测:MTCNN
DETR(Detection with Transformers) 学习笔记
模型过拟合-解决方案(二):Dropout
Leetcode 2200. 找出数组中的所有 K 近邻下标(可以,一次过)
[Part 8] semaphore source code analysis and application details [key points]
RT thread quick start - experience RT thread
Record 5 - the serial port of stm32f411ceu6 realizes the sending and receiving of fixed length data and variable length data
Design of traceid in the project
[issue 30] shopee golang development experience
The "fourteenth five year plan" development plan and panoramic strategic analysis report of China's information and innovation industry 2022 ~ 2028
The carrying capacity of L2 level ADAS increased by more than 60% year-on-year in January, and domestic suppliers "emerged"
Don't write about the full screen explosion, try the decorator mode, this is the elegant way!!
Go time format assignment
Matters of parent-child class construction method in inheritance
Colab教程(超级详细版)及Colab Pro/Colab Pro+使用评测
[redis sentinel] failed listening on port 26379 (TCP) & sentinel mode no response problem solved
Qrcodejs2 QR code generation JS