Topic 5: Data Structures
来源:互联网 发布:中国纺织业出口数据 编辑:程序博客网 时间:2024/06/05 12:03
1. Data structure:
List
Tuples and Sequences
Sets
Dictionary
2. Methods of list object:
list.append(x)
list.extend(L)
list.insert(i,x) You can test the position.
list.remove(x)
list.pop(i) remove the item at the given position and return it.
list.pop() by default i=len(list), it's the last item
list.clear()
list.index(x) returns the index in the list of the item whose value is x
list.count(x)
list.sort()
list.reverse()
list.copy()
3. Methods that have no return values printed return None
4. Lists can be used as stacks by using the methods list.pop() and list.append.
5. Using lists as queues is not efficient!( Because all of the other elements have to be shifted by one)
collections.deque can do some help
6. concise 简洁的
7. List comprehensions
a_list=list(range(5))
[(x,x**2) for x in a_list]
8. Nested List Comprehension
9. del a[2:4]
del a
10. A tuple consists of a number of values separated by commas.
t=11,2,23,'dbvsxd'
empty_tuple=()
singleton='Hello',
immutable
11. Sets
No order, no duplication.
empty_set=set()
empty_dictionary={}
a=set('alacazam')
b=set('fasfsd')
a-b
a|b letters in either a or b
a&b
a^b letters in a or b but not both=a|b-a&b
12. Dictionary indexed by keys
13.
14.
15.
16.
17.
18.
19. How to delete the duplicate words?Here we go!
list->set->list
20. assignment cannot occur inside expression
21.
- Topic 5: Data Structures
- Data Structures
- data structures
- Data Structures
- data structures
- Data Structures
- Data Structures
- Data Structures - Immutable Data Structures
- Data Structures (Weiss) Chapter 5: Separate Chain
- Data Structures and Algorithms
- Data Structures Demystified
- Data Structures and Algorithms
- Disjoint-set Data Structures
- C & Data Structures
- Data Structures Demystified
- Data Structures, Suffix Trees
- Data Structures, Fall 2007
- Data Structures implementations:SimpleArray
- iOS被爆存在安全漏洞,邮箱附件无需使用密钥即可解密
- 小米电视支付SDK接入air坑爹之路
- recvmsg与sendmsg函数
- Hibernate 错误解决(TransactionException: Transaction not successfully started)
- iOS UIPopoverController的使用
- Topic 5: Data Structures
- 最小生成树prim算法实现及1233解题思路
- Sublime Text 2 强大的编辑功能
- Cocos2D-X2.2.3学习笔记2(坐标系统)
- js 在不同浏览器中一些常见的兼容性问题
- 计算机改名引发的ORA-12541: TNS无监听程序错误
- 关于oracle的start with connect by 的使用
- iOS录音和播放
- 第十一周项目2 职员有薪水了