吴裕雄--天生自然 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 ...
随机推荐
- 微服务中一个项目install打包总是失败
在微服务的一个项目中install打包时总是报错如下: [INFO] Scanning for projects... [INFO] [INFO] -------------------------- ...
- EBGP的多跳与验证命令
EBGP的多跳与验证命令: ①:neighbor router-id ebgp-multihop “int”——设置多跳. ②:neighbor router-id password “str”——设 ...
- POJ-3629 模拟
A - Card Stacking Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u S ...
- Django回顾之_03_Model属性及后端配置
1. Django ORM O(objects):类和对象. R(Relation):关系,关系数据库中的表格. M(Mapping):映射. Django ORM框架的功能: a) 建立模型类和表之 ...
- 配置自己的sublime
我配置的sublime的是这样的,就是在input里输入数据,然后在output里可以得到数据,这样比较方便,看到有的大神还配置背景和其他的,有时间搞一下: 首先把编译器g++配置到环境变量,可以从d ...
- POJ 2676:Sudoku 数独
Sudoku Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 15830 Accepted: 7737 Special ...
- django_filter的values / values_list
from django.db import models class Blog(models.Model): name = models.CharField(max_length=100) tagli ...
- XML文件读写编码不是UTF-8的问题
FileWriter和FileReader在写.读文件时,使用系统当前默认的编码方式. 在中文win下encoding基本是GB2312,在英文win下基本是ISO-8859-1.所以要创建一个UTF ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习:DOM EventListener
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- pip常见使用方法
pip可以理解类似yum管理rpm包的管理python包工具 pip参数解释 pip --help Usage: pip <command> [options] Commands: ins ...