交集,并集,差集,函数

ale=["a","b","c"]  you=["a","e","s"]

f=set(ale)

g=set(you)            set把列表放到集合里去

交集:interscetion

  print(f.intersection g)

  print(f&g)

并集:union

  print(f.union g)

  print(f|g)

差集:

  print(f-g)

注意事项:

1.不可变集合:frozenset

  q=frozenset(ale)

2.去重并列列表:

  p=lise(set(ale))

函数

1.def test(x):

  "j解释含义"

  return y #返回结果

  print(test)

  a=text(x变量)

  print(a)

猜你喜欢

转载自www.cnblogs.com/cui00/p/11436358.html