一、集合
1.集合的值不能重复,重复的值会被自动剔除
2.集合的并集用符号 “|”
3.集合的交集用符号“&”
4.集合的差集用符号“-”
5.集合的对衬差集用符号“^”
myset1={1,2,3,4,5} myset2={5,6,7,8,4} myset1|myset2 Out[7]: {1, 2, 3, 4, 5, 6, 7, 8} myset1&myset2 Out[8]: {4, 5} myset1-myset2 Out[9]: {1, 2, 3} myset2-myset1 Out[11]: {6, 7, 8} myset1^myset2 Out[12]: {1, 2, 3, 6, 7, 8}View Code
二、条件语句
1.单行条件语句
a=10
b=30
c=a if a>b else b #c被赋值前,会先进行a和b的值大小对比
此时 c=30