zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然 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)
  • 相关阅读:
    活着的目标
    Online Judge(OJ)搭建——2、数据库,SQL语句
    《Docker 实战》第三章 Docker Hub 寻宝游戏
    2017年计划
    IDEA 问题 & 解决
    IDEA 自动化配置
    bzoj 3796: Mushroom追妹纸【二分+后缀数组+st表】
    CF487E Tourists【圆方树+tarjan+multiset+树剖+线段树】
    bzoj 1023: [SHOI2008]cactus仙人掌图【tarjan+dp+单调队列】
    bzoj 4316: 小C的独立集【仙人掌dp】
  • 原文地址:https://www.cnblogs.com/tszr/p/10963246.html
Copyright © 2011-2022 走看看