当前位置:网站首页>Section 12 of Chapter 2: set set
Section 12 of Chapter 2: set set
2022-07-21 15:15:00 【Zhongyifeng Digital Technology Co., Ltd】
Python Basic introduction ( A full set of nanny level tutorials )
Chapter two
Section 12 :set aggregate
set aggregate , set Sets are unordered
Do not hash : python Medium set When a collection stores data . You need to hash the data , Store data according to the calculated hash value set The set requires that the stored data must be hashable . Variable data types , list, dict, set
Can hash : Immutable data types , int, str, tuple, bool.
s = {
1," Ha ha Da ",2,3}
print(type(s))
print(s)
# Here is set Only hashable ones can be placed in it .
s = {
1, 2, 3, " ha-ha ", (1, 2, 3), []} # unhashable type: 'list'
print(s)
add increase
s = set() # Create an empty set
s.add(" Zhao Benshan ")
s.add(" Fan Wei ")
s.add(" Gentiana ")
print(s)
remove Delete
Want to modify . Delete first . Add new
for loop , Used for query
s.remove(" Gentiana ")
s.add(" Shen Tang ")
print(s)
for item in s:
print(item)
summary :
set aggregate , set Sets are unordered
add increase
remove Delete
for loop , Used for query
The key is to understand hash
Do not hash : python Medium set When a collection stores data . You need to hash the data , Store data according to the calculated hash value set The set requires that the stored data must be hashable . Variable data types , list, dict, set
Can hash : Immutable data types , int, str, tuple, bool.
边栏推荐
- Opportunities and challenges coexist for financial enterprises to go to sea in emerging markets, advance AI ensures its safety and compliance development
- DAMA-第七章(数据安全)
- Lora技术助力冷链发展
- double、float、long占几个字节?
- DAMA-第九章(文件与内容管理)
- Kingbasees database administrator's Guide -- 17 database scheduling concept
- 北大同宿舍三人毕业后分别去外企、国企、创业,10年后都后悔什么
- 【C 练习】将字符串中的空格转换为「%20」
- 第二章第十节:列表的补充知识点
- 带你认识一下数仓的分区自动管理
猜你喜欢
Design details related to sap e-commerce cloud Spartacus UI store
【C 练习】求一个数最少需要多少步可变为斐波那契数
Spark Sql编译模块-词法、语法分析器Antlr4(一
Rasterization comprehensive analysis
虚拟机内核参数永久生效配置
Intel assembly language programming learning - Chapter 5 process - Part 1
Web3 Traffic Aggregation Platform Starfish os, Explaining Real Business' p2e 'Ecology
第二章第六节:字符串的补充和总结
Web3 traffic aggregation platform starfish OS gives players a new paradigm experience of metauniverse
Intel assembly language programming learning - Chapter 5 process - Part 1
随机推荐
Kingbasees database administrator's Guide -- 15.3 Management synonyms
leetcode:689. Maximum sum of three non overlapping subarrays
leetcode:689. 三个无重叠子数组的最大和
asp.net -编辑超链接事件
银行数据管理办法
第二章 第八节:列表的增删改查
Mysql的主键UUID、自增ID、雪花算法到底该怎么选择?(荣耀典藏版)
Deep copy function
乘数科技云管控平台适配阿里云 PolarDB,共促云原生数据库生态繁荣
深拷贝函数
evil spirits
[quick start tutorial 3] crazy shell · open source formation UAV - development environment construction
leetcode:42. Connect rainwater
魑魅魍魎
DevExpress TreeList 实现父节点列值选中,其下子节点也全部选中
Web3 traffic aggregation platform starfish OS gives players a new paradigm experience of metauniverse
第二章第九节:练习答案
.NET Core 加载程序集AssemblyLoadContext
Arithmetic operator 2 (Gretel software - Jiuye practical training)
DAMA-第四章(数据架构)