吴裕雄--天生自然 PYTHON3开发学习:集合
fruits = {"apple", "banana", "cherry"}
fruits.add("orange")
print(fruits)
fruits = {"apple", "banana", "cherry"}
fruits.clear()
print(fruits)
fruits = {"apple", "banana", "cherry"}
x = fruits.copy()
print(x)
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.difference(y)
print(z)
x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
x.difference_update(y)
print(x)
fruits = {"apple", "banana", "cherry"}
fruits.discard("banana")
print(fruits)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
z = x.intersection(y)
print(z)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
x.intersection_update(y)
print(x)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "facebook"}
z = x.isdisjoint(y)
print(z)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
z = x.isdisjoint(y)
print(z)
fruits = {"apple", "banana", "cherry"}
fruits.pop()
print(fruits)
fruits = {"apple", "banana", "cherry"}
fruits.remove("banana")
print(fruits)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
z = x.symmetric_difference(y)
print(z)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
x.symmetric_difference_update(y)
print(x)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
z = x.union(y)
print(z)
x = {"a", "b", "c"}
y = {"f", "d", "a"}
z = {"c", "d", "e"}
result = x.union(y, z)
print(result)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
z = x.union(y)
print(z)
x = {"a", "b", "c"}
y = {"f", "d", "a"}
z = {"c", "d", "e"}
result = x.union(y, z)
print(result)
x = {"apple", "banana", "cherry"}
y = {"google", "runoob", "apple"}
x.update(y)
print(x)
吴裕雄--天生自然 PYTHON3开发学习:集合的更多相关文章
- 吴裕雄--天生自然 PYTHON3开发学习:基本数据类型
#!/usr/bin/python3 counter = 100 # 整型变量 miles = 1000.0 # 浮点型变量 name = "runoob" # 字符串 print ...
- 吴裕雄--天生自然 PYTHON3开发学习:MySQL - mysql-connector 驱动
import mysql.connector mydb = mysql.connector.connect( host="localhost", # 数据库主机地址 user=&q ...
- 吴裕雄--天生自然 PYTHON3开发学习:列表
list1 = ['Google', 'Runoob', 1997, 2000]; list2 = [1, 2, 3, 4, 5 ]; list3 = ["a", "b& ...
- 吴裕雄--天生自然 PYTHON3开发学习:字符串
var1 = 'Hello World!' var2 = "Runoob" #!/usr/bin/python3 var1 = 'Hello World!' var2 = &quo ...
- 吴裕雄--天生自然 PYTHON3开发学习:数字(Number)
print ("abs(-40) : ", abs(-40)) print ("abs(100.10) : ", abs(100.10)) #!/usr/bin ...
- 吴裕雄--天生自然 PYTHON3开发学习:运算符
#!/usr/bin/python3 a = 21 b = 10 c = 0 c = a + b print ("1 - c 的值为:", c) c = a - b print ( ...
- 吴裕雄--天生自然 PYTHON3开发学习:基础语法
#!/usr/bin/python3 # 第一个注释 print ("Hello, Python!") # 第二个注释 #!/usr/bin/python3 # 第一个注释 # 第 ...
- 吴裕雄--天生自然 PYTHON3开发学习:函数
def 函数名(参数列表): 函数体 # 计算面积函数 def area(width, height): return width * height def print_welcome(name): ...
- 吴裕雄--天生自然 PYTHON3开发学习:MongoDB
import pymongo myclient = pymongo.MongoClient("mongodb://localhost:27017/") mydb = myclien ...
随机推荐
- grep -q
grep -q用于if逻辑判断 安静模式,不打印任何标准输出.如果有匹配的内容则立即返回状态值0. grep -q的用法 # if grep -q hello a.txt ; then ...
- c++ STD Gems07
reverse.rotate.permutation #include <iostream> #include <vector> #include <string> ...
- <老古董>1962年的线性支持向量机解法
我们说“训练”支持向量机模型,其实就是确定"最大间隔超平面". 用数学语言来说就是确定一个最优的W.好比训练一个逻辑回归模型的目的是确定最优的W和b. 输入 X,为一个n维向量 输 ...
- HZNU-ACM寒假集训Day5小结 线段树 树状数组
线段树 什么时候用线段树 1.统计量可合并 2.修改量可合并 3.通过统计量可直接修改统计量 一句话:满足区间加法即可使用线段树维护信息 理解Lazy Tage 蓝色是要把信息及时维护的节点,红色是本 ...
- centos 通过命令查找已安装的部署包名称
场景: 服务器上已经安装了sz命令,但是我们想知道他是哪个包安装的. 步骤一: [root@localhost home]# whereis sz sz: /usr/bin/sz /usr/share ...
- spring boot集成mybatis(3) - mybatis generator 配置
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- Oracle 查询重复数据方法
查询某个字段存在重复数据的方法: select * from tablename where id in (select id from tablename group by id having co ...
- POJ 3126:Prime Path
Prime Path Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u Submit St ...
- springboot--入门(了解springboot)
个人认为,springboot和maven差不多.maven方便我们管理jar包,而springboot帮助我们简化spring的配置. 未完,待续.......
- CSS(3)之 less 和rem
less 预编译脚本语言. LESS 语法 less语法2 LESS中文 rem rem的适配原理 rem 是相对于页面根源素html的字体大小的一个尺寸单位 页面内容可以使用rem为单位,那么htm ...