《计算机科学导论》学习笔记(15) - 课程 15 响应查询

xiaoxiao2021-02-28  24

课程 15:响应查询

1. 简介

2. 练习:数据结构

3. 练习:添加索引

题目:

# Define a procedure, add_to_index, # that takes 3 inputs: # - an index: [[<keyword>,[<url>,...]],...] # - a keyword: String # - a url: String # If the keyword is already # in the index, add the url # to the list of urls associated # with that keyword. # If the keyword is not in the index, # add an entry to the index: [keyword,[url]] index = [] def add_to_index(index,keyword,url): #add_to_index(index,'udacity','http://udacity.com') #add_to_index(index,'computing','http://acm.org') #add_to_index(index,'udacity','http://npr.org') #print index #>>> [['udacity', ['http://udacity.com', 'http://npr.org']], #>>> ['computing', ['http://acm.org']]]

我的答案(我搞不出来…):

def add_to_index(index,keyword,url): if index. index.append([keyword, [url]]) """ for i in range(len(index)): if keyword not in index[i]: index.append([keyword]) for i in range(len(index)): if len(index[i]) == 1: index[i].append([]) if index[i][0] == keyword: index[i][1].append(url) """ """ for i in range(len(index)): if index[i][0] == keyword: index[i][1].append(url) return index """

视频的答案(我看的不是很懂):

index = [] def add_to_index(index,keyword,url): for e in index: if e[0] == keyword: e[1].append(url) return index.append([keyword, [url]]) add_to_index(index,'udacity','http://udacity.com') add_to_index(index,'computing','http://acm.org') add_to_index(index,'udacity','http://npr.org') print index #>>> [['udacity', ['http://udacity.com', 'http://npr.org']], #>>> ['computing', ['http://acm.org']]]

4. 练习:查询

5. 构建网络索引

6. 练习:添加页面至索引

7. 练习:完成网络爬虫

8. 启动

9. 因特网

10. 练习:网络

11. 烟幕信号

12. 练习:延迟

13. 带宽

14. 练习:比特

15. 比特桶

16. 练习:你的带宽是多少?

17. 跟踪路由

( Linux 下的跟踪方式: 1 . 安装 traceroute :

$ sudo apt-get install traceroute 跟踪访问某个网站的路由: $ traceroute www.udacity.com

)

18. 练习:传输数据

19. 制造网络

20. 协议

21. 结论

转载请注明原文地址: https://www.6miu.com/read-2000245.html

最新回复(0)