Error in user YAML: (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1
---
- oeasy Python 0128
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
本教程同步发布在:
个人网站: `https://oeasy.org`
蓝桥云课: `https://www.lanqiao.cn/courses/3584`
GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
Gitee: `https://gitee.com/overmind1980/oeasypython`
---
运算名称
方法名
运算符
交集
intersection
&
并集
union
|
差集
difference
-
对称差集
symmetric_difference
^
运算名称
方法名
运算符
交集
intersection
&
并集
union
|
差集
difference
-
对称差集
symmetric_difference
^
交集并更新 intersection_update
s1 = {1 , 2 , 3 }
s2 = {3 , 4 , 5 }
s1 .intersection (s2 )
s1
s1 .intersection_update (s2 )
s1
s2
s1 = {1 , 2 , 3 }
s2 = {3 , 4 , 5 }
s1 &= s2
s1
s2
date
以前 文档落款 有 日期时间
计算机时代 更新文档 会更新时间戳
update
将文档、数据、程序向上(up)
更新到最新的日期(date)
通过定义可以知道
update 函数是将当前集合和参数集合求并
然后更新
s1 = {1 , 2 , 3 }
s2 = {3 , 4 , 5 }
s1 .union (s2 )
s1
s1 .update (s2 )
s1
s2
s1 = {1 , 2 , 3 }
s2 = {3 , 4 , 5 }
s1 |= s2
s1
s2
s1 = {1 , 2 , 3 }
s2 = {3 , 4 , 5 }
s1 .difference (s2 )
s1
s1 .difference_update (s2 )
s1
s2
s1 = {1, 2, 3}
s2 = {3, 4, 5}
s1 -= s2
s1
s2
s1 = {1, 2, 3}
s2 = {3, 4, 5}
s1.symmetric_difference(s2)
s1
s1.symmetric_difference_update(s2)
s1
s2
s1 = {1, 2, 3}
s2 = {3, 4, 5}
s1 ^= s2
s1
s2
运算类型
基础运算符
增强赋值运算符
对应方法名
交集
&
&=
intersection
并集
|
|=
union
差集
-
-=
difference
对称差集
^
^=
symmetric_difference
本文来自 oeasy Python 系统教程。
想完整、扎实学 Python,
搜索 oeasy 即可。