Set 集合 set - unordered collections of unique elements 创建一个set/一个空set # create a new set set1 = {1,2,3} print(type(set1)) # result => <class 'set> set2 = set() print(type(set2)) # create an empty set, result => <class 'set'> # as the obje…
三目运算:and/or 技巧 and, or 联合起来有个小技巧: print 2 < 3 and True or False 说明: 如果 2 小于 3 了,则输出 True , 否则输出 False 代码示例: In [1]: var = 2 < 3 and True or False In [2]: print var In [3]: print 3 != 3 and 'OK' or 'Failure' 说明 and 前是判定条件,or 前后分别是判定正确和错误的返回值. 注…