Set
screaming
这个作者很懒,什么都没留下…
展开
-
Python list vs set
本来是知道在Python中使用Set是比较高效,但是没想到竟然有这么大的差距:~$ python -m timeit -n 1000 "[x for x in range(1000) if x in range(500, 1500)]" 1000 loops, best of 3: 28.2 msec per loop ~$ python -m timeit -n 1000转载 2016-05-27 15:21:37 · 510 阅读 · 0 评论 -
Python set
A set object is an unordered collections of DISTINCT hashable objectsUsed for membership testing / removing duplicates from a sequence / Computing mathematical operations such as intersection, union转载 2016-05-27 15:32:33 · 323 阅读 · 0 评论 -
dict & set
使用dict和setReads: 162084dictPython内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度。举个例子,假设要根据同学的名字查找对应的成绩,如果用list实现,需要两个list:names = ['Michael', 'Bob', 'Tr转载 2016-04-22 14:56:46 · 306 阅读 · 0 评论 -
Python Looping enumerate, reversed, sorted, iteritems, zip
Looping TechniquesWhen looping through a sequence, the position index and corresponding value can be retrieved at the same time using the enumerate() function.>>>>>> for i, v in enumerate(['转载 2016-06-03 15:06:51 · 435 阅读 · 0 评论 -
python set operation
Set can be converted to list by list(set)add(elem)¶Add element elem to the set.remove(elem)Remove element elem from the set. Raises KeyError if elem is not contained in the set.转载 2016-06-04 00:35:49 · 616 阅读 · 0 评论 -
Python Set operation
PythonBuilt-inDictionaryListSetTuple2DArrayBytesClassConsoleConvertDatetimeDelDuplicatesErrorFileFindIfLambdaLenLowerMapMathNamedtupleOrdRandomReSliceSortSplitStringStripSubSubstringTypeWhileSet. A转载 2016-06-11 23:20:17 · 482 阅读 · 0 评论