昨天没来及整理博客,有点小累。休息了一下,今天的内容比较多

集合还是按照之前的方法,整理了一边所有的方法,其次在看了下format的方法

还有一些函数,暂时学了一点 还不知道怎么整理

s = {1,2,3,5,'s','s','d','z'}
s1 = {1,9,8,7,'b','c','s'}
# 随机删除
print(s.pop())
print(s)
# 删除一个成员,如果没有会报错
s.remove(2)
print(s)
# 删除一个成员,如果没有不会报错
s.discard(23232)
print(s)
# 添加
s.add("f")
print(s)
# 交集
v = s.intersection(s1)
print(s&s1)
print(v)
# 并集
print(s.union(s1))
print(s|s1)
# 减集
print(s.difference(s1))
print(s-s1)
# 交叉补集
print(s.symmetric_difference(s1))
print(s^s1)
# 是否没有相同
print(s.isdisjoint(s1))
s = {1,2}
s1 = {1,2,"s","d"}
# 是否被其他集合包含(为子集)
print(s.issubset(s1))
s2 = {1,2}
s3 = {1,2,"s","d"}
# 是否包含其他集合(为父集)
print(s3.issuperset(s2))
# 不按照顺序去重
s = [1,2,3,5,'s','s','d','z']
s = list(set(s))
print(s)
tpl = "i am {}, age {}, {}".format("seven", 18, 'alex')
  
tpl = "i am {}, age {}, {}".format(*["seven", 18, 'alex'])
  
tpl = "i am {0}, age {1}, really {0}".format("seven", 18)
  
tpl = "i am {0}, age {1}, really {0}".format(*["seven", 18])
  
tpl = "i am {name}, age {age}, really {name}".format(name="seven", age=18)
  
tpl = "i am {name}, age {age}, really {name}".format(**{"name": "seven", "age": 18})
  
tpl = "i am {0[0]}, age {0[1]}, really {0[2]}".format([1, 2, 3], [11, 22, 33])
  
tpl = "i am {:s}, age {:d}, money {:f}".format("seven", 18, 88888.1)
  
tpl = "i am {:s}, age {:d}".format(*["seven", 18])
  
tpl = "i am {name:s}, age {age:d}".format(name="seven", age=18)
  
tpl = "i am {name:s}, age {age:d}".format(**{"name": "seven", "age": 18})
 
tpl = "numbers: {:b},{:o},{:d},{:x},{:X}, {:%}".format(15, 15, 15, 15, 15, 15.87623, 2)
 
tpl = "numbers: {:b},{:o},{:d},{:x},{:X}, {:%}".format(15, 15, 15, 15, 15, 15.87623, 2)
 
tpl = "numbers: {0:b},{0:o},{0:d},{0:x},{0:X}, {0:%}".format(15)
 
tpl = "numbers: {num:b},{num:o},{num:d},{num:x},{num:X}, {num:%}".format(num=15)