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开发学习:集合的更多相关文章

  1. 吴裕雄--天生自然 PYTHON3开发学习:基本数据类型

    #!/usr/bin/python3 counter = 100 # 整型变量 miles = 1000.0 # 浮点型变量 name = "runoob" # 字符串 print ...

  2. 吴裕雄--天生自然 PYTHON3开发学习:MySQL - mysql-connector 驱动

    import mysql.connector mydb = mysql.connector.connect( host="localhost", # 数据库主机地址 user=&q ...

  3. 吴裕雄--天生自然 PYTHON3开发学习:列表

    list1 = ['Google', 'Runoob', 1997, 2000]; list2 = [1, 2, 3, 4, 5 ]; list3 = ["a", "b& ...

  4. 吴裕雄--天生自然 PYTHON3开发学习:字符串

    var1 = 'Hello World!' var2 = "Runoob" #!/usr/bin/python3 var1 = 'Hello World!' var2 = &quo ...

  5. 吴裕雄--天生自然 PYTHON3开发学习:数字(Number)

    print ("abs(-40) : ", abs(-40)) print ("abs(100.10) : ", abs(100.10)) #!/usr/bin ...

  6. 吴裕雄--天生自然 PYTHON3开发学习:运算符

    #!/usr/bin/python3 a = 21 b = 10 c = 0 c = a + b print ("1 - c 的值为:", c) c = a - b print ( ...

  7. 吴裕雄--天生自然 PYTHON3开发学习:基础语法

    #!/usr/bin/python3 # 第一个注释 print ("Hello, Python!") # 第二个注释 #!/usr/bin/python3 # 第一个注释 # 第 ...

  8. 吴裕雄--天生自然 PYTHON3开发学习:函数

    def 函数名(参数列表): 函数体 # 计算面积函数 def area(width, height): return width * height def print_welcome(name): ...

  9. 吴裕雄--天生自然 PYTHON3开发学习:MongoDB

    import pymongo myclient = pymongo.MongoClient("mongodb://localhost:27017/") mydb = myclien ...

随机推荐

  1. JS隔行换色和全选的实现

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. git修改已经push的commit message

    git中修改上一次提交的commit的message git commit --amend -m "你的新的注释" git push -f 多个commit https://www ...

  3. 每天一点点之vue框架开发 - axios拦截器的使用

    <script> import axios from 'axios' export default { name: 'hello', data () { return { msg: 'We ...

  4. 线程与进程 concurrent.futures模块

    https://docs.python.org/3/library/concurrent.futures.html 17.4.1 Executor Objects class concurrent.f ...

  5. 滴滴与Uber都盯上拉美市场!一场惨烈竞争谁能胜出?

    创业者最怕的是什么?或许并不是在创业初期的艰难历程.毕竟在初期虽然会遇到很多磨难和众多竞争对手,但只要敢打敢拼就有胜出的可能.创业者最怕的或许是成为所属行业独角兽后,要面对势均力敌对手的凶猛攻击!大家 ...

  6. EF Core开发模式之Code First

    Code First顾名思义,代码为先.首先编写完相关的实体类及DbContext派生类,然后通过映射关系自动在数据库中完成数据库表的创建. 本例中创建一个班级和学生的管理,主要有班级类MyClass ...

  7. Mysql数据库忘记密码找回方法

    Mysql数据库忘记密码找回 a 停止mysql服务 /etc/init.d/mysql stop b 使用--skip-grant-tables启动mysql,忽略授权登录验证 mysqld_saf ...

  8. java-简单工程模板

    1.maven <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all< ...

  9. 201771010123汪慧和《面向对象程序设计Java》第二周学习总结

    一.理论知识部分 1.标识符由字母.下划线.美元符号和数字组成, 且第一个符号不能为数字.标识符可用作: 类名.变量名.方法名.数组名.文件名等.第二部分:理论知识学习部分 2.关键字就是Java语言 ...

  10. python numpy和矩阵

    2.numpy数据选取 lst=[[1, 2, 3], [4, 5, 6]] np.array(lst)[:-1] Out[32]: array([[1, 2, 3]]) np.array(lst)[ ...