# 基本数据类型及内置方法

#默认情况下都是浅copy

""" #遍历：所有取一遍

l1 = [111,222,[333,444]] #所有可以被for循环遍历的类型都可以传给list然后转换成列表

l2 = l1.copy()

l3 = l1[:]

#print(id(l1[0]),id(l1[1]),id(l1[2]))

#print(id(l2[0]),id(l2[1]),id(l2[2]))

#l1[2][0] = 666

l1[0] = 777

print(l1)

print(l2)

man = ["上海",[100,]]

woman = man.copy()

man[1][0] -= 30

print(man)

print(woman)

"""

#2、深copy

from copy import deepcopy

l1 = [111,222,[333,444]]

l2 = deepcopy(l1)

print(id(l1[0]),id(l1[1]),id(l1[2]))

print(id(l2[0]),id(l2[1]),id(l2[2]))

l1[2][0] = 666

print(l1)

print(l2)

#l1[0] = 777

#print(l1)

#======set基本使用===========

1、用途：

（1）关系运算

（2）去重

#pythons = ["egon",'lxx',"张全蛋","李铁蛋",'刘金蛋',"赵银弹"]

#Linuxs = ['lili','jack','egon','lxx','tom','kkk']

#l = []

#for stu in pythons:

#if stu in Linuxs:

l.append(stu)

#print(l)

#2、定义方式: 在{}内用逗号分割开多个元素，需要注意的是集合的元素必须满足

#1、集合的元素必须是不可变类型

#2、集合的元素无序

#3、集合的元素没有重复

#s = {}

#print(type(s)) # 空字典

#s = set() # 定义空集合

#s = {1,'a',2,'b',3,'b','b','b'} # s=set({1,2,3})

#print(type(s))

#print(s)

#set数据类型转换

#res = set("hello")

#res = set([111,222,333,111,[666,777]])

#print(res)

#3、常用操作+内置的方法

#3.1 去重

student = [

{"name":"egon1","age":18,"gender":'male'}

{"name":"egon2","age":19,"gender":'female'},

{"name":"egon3","age":17,"gender":'female'},

{"name":"egon1","age":18,"gender":'male'},

{"name":"egon1","age":18,"gender":'male'},

]

#new_l = []

#for info in student:

#if info not in new_l:

#new_l.append(info)

#print(new_l)

pythons = {"egon",'lxx',"张全蛋","李铁蛋",'刘金蛋',"赵银弹"}

Linuxs = {'lili','jack','egon','lxx','tom','kkk'}

##（1）交集：求既报名pyton又报名Linux的学员姓名

#print(pythons & Linuxs)

#print(pythons.intersection(Linuxs)) #intersection：交叉 ； section：部分，截面

##(2)并集:求所有学生姓名

#print(pythons | Linuxs)

#print(pythons.union(Linuxs))

#(3)差集: 求只报名python的学员姓名

#print(pythons - Linuxs)

#print(pythons.difference(Linuxs))

#print(Linuxs - pythons)

#(4)对称差集：求没有同时报名两门课程的学员

#res = (pythons - Linuxs) | (Linuxs - pythons)

#res = pythons ^ Linuxs

#print(res)

res = pythons.symmetric_difference(Linuxs) #symmetric：对称的，匀称的

print(res)

#(5) 父子集：父子指的包含与被包含的关系

#父集：>=

#子集：<=

#s1 = {1,2,3}

#s2 = {1,2}

#print(s1 >= s2) # >=等同于.issuperset

#print(s1.issuperset(s2))

#print(s2 <= s1) # <=等同于.issubset

#print(s2.issubset(s1))

#s1 = {1,2,3}

#s2 = {1,2,4}

#print(s1 > s2)

#print(s1 < s2)

#s1 = {1,2,3}

#s2 = {1,3,2}

#print(s1 == s2)

#s1 >= s2

#了解的内置方法

s1 = {'a',1,2,3}

#res = s1.pop() #随机删一个

#res = s1.remove(2) #指定删，无返回值

#s1.remove(4) 删除不存在元素会报错

#print(s1)

#print(res)

#s1.update({4,5,6,3}) #再传一个集合进去

#s1 = s1.difference({3,4,5})

#s1.difference_update({3,4,5})

#print(s1.isdisjoint({3,4,5,6})) #无交集为真

#print(s1)

s1 = {111,222,333,444,555}

for x in s1:

print(x)

#================该类型总结====================================

#存多个值 #无法取某个值

#无序

#set集合可变,frozenset不可变集合

#s1 = {1,2,3}

#print(id(s1))