From c8e4f4f34ff4f49a66d08b015a180b0634dd686b Mon Sep 17 00:00:00 2001 From: Administrator <616697902@qq.com> Date: Mon, 14 Oct 2019 11:39:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Python1903=E7=8F=AD=E9=99=88=E6=B3=93?= =?UTF-8?q?=E7=BE=BD=E6=8F=90=E4=BA=A4=E9=9D=A2=E8=AF=95=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-interview-2019-3.md | 68 ++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/python-interview-2019-3.md b/python-interview-2019-3.md index 66cf49b..eb44d3f 100644 --- a/python-interview-2019-3.md +++ b/python-interview-2019-3.md @@ -2,7 +2,7 @@ > **答题要求**:将该项目从[地址1]()或[地址2]()**fork**到自己的[GitHub]()或[Gitee](https://gitee.com)仓库并在线填写答案,完成后以发送合并请求(**Pull Request**)的方式提交自己的工作成果,时间120分钟。 -#### 答题人: +#### 答题人:陈泓羽 #### 题目: @@ -17,14 +17,16 @@ 答案: ``` - + ('abcd',(1,2,3,4,5)) + {1:'item{1},2:'item{9}'} + 5 ``` 2. 下面的Python代码会输出什么。 ```Python from functools import reduce - + items = [11, 12, 13, 14] print(reduce(int.__add__, map(lambda x: x // 2, filter(lambda x: x ** 2 > 150, items)))) ``` @@ -32,7 +34,7 @@ 答案: ``` - + 13 ``` 3. 对于第2题的代码,如果要实现相同的功能,用生成式应该怎么写? @@ -40,7 +42,7 @@ 答案: ```Python - + sum([x // 2 for i in items if i ** 2 > 150]) ``` 4. 用一行代码实现将字符串`k1:v1|k2:v2|k3:v3`处理成字典`{'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}`。 @@ -48,7 +50,7 @@ 答案: ```Python - + {k: v for k, v in map(lambda x: x.split(':'), s.split('|'))} ``` 5. 写一个装饰函数的装饰器,实现如果函数的返回值是字符串类型,就将该字符串每个单词的首字母大写(不用考虑非英文字符串的情况)。 @@ -56,7 +58,12 @@ 答案: ```Python - + def word(func): + def wrapper(*args,**kwargs): + result = func(*args,**kwargs) + new_result = result.capitalize() + return new_result + return wrapper ``` 6. 下面的字典中保存了某些公司股票的代码(字典中的键)及价格(字典中的值,以美元为单位),用一行代码从中找出价格最高的股票对应的股票代码,再用一行代码将股价高于100美元的股票创建成一个新的字典。 @@ -78,7 +85,8 @@ 答案: ```Python - + max(prices,key=lambda k: prices[k]) + {k:v for k,v in prices.items() if v >100} ``` 7. 写一个函数,返回删除列表中重复元素后的新列表,要求保留原有列表元素的顺序。 @@ -86,7 +94,10 @@ 答案: ```Python - + def list1(list): + new_list = [] + new_list.append(i) for i in list if i not in new_list + return new_list ``` 8. 写一个函数,该函数的参数是一个保存字符串的列表,列表中某个字符串出现次数占列表元素总数的半数以上,找出并返回这个字符串。 @@ -94,7 +105,9 @@ 答案: ```Python - + def find_str(list): + result = i for i in list if list.count(i) > len(list)/2 + return result ``` 9. MySQL关系型数据库中有三张表分别表示用户、房源和租房记录,表结构如下所示。 @@ -146,23 +159,44 @@ 答案: ```SQL - + select usename + from tb_user + where userid in (select userid from tb_record where houseid=1055) + + select username + from tb_user + where userid in (select userid from tb_record group by recid having count(userid)>3) + and usertel is not null + + select houseid,title + from tb_house + where houseid in + (select houseid from tb_record where indate > 2018.1.1 group by recid having count(houseid) >2) + where rented is null and area > 50 ``` 10. 请阐述访问一个用Django或Flask开发的Web应用,从用户在浏览器中输入网址回车到浏览器收到Web页面的整个过程中,到底发生了哪些事情,越详细越好。 - 答案: + 答案: - ``` - - ``` + ``` + + ``` 11. 请阐述HTTPS的工作原理以及TCP是如何保证端到端可靠传输的。 答案: ``` - + 1.客户使用https的URL访问Web服务器,要求与Web服务器建立SSL连接。 +   2.Web服务器收到客户端请求后,会将网站的证书信息(证书中包含公钥)传送一份给客户端。 +   3.客户端的浏览器与Web服务器开始协商SSL连接的安全等级,也就是信息加密的等级。 +   4.客户端的浏览器根据双方同意的安全等级,建立会话密钥,然后利用网站的公钥将会话密钥加密,并传送给网站。 +   5.Web服务器利用自己的私钥解密出会话密钥。 +   6.Web服务器利用会话密钥加密与客户端之间的通信。 +    +   TCP利用了慢启动机制和ACK验证来保证数据的有效传输和可靠传输,防止丢包。 + ``` 12. 在Linux系统中,假设Nginx的访问日志位于`/var/log/nginx/access.log`,该文件的每一行代表一条访问记录,每一行都由若干列(以制表键分隔)构成,其中第1列记录了访问者的IP地址,如下所示。请用一行命令找出最近的100000次访问中,访问频率最高的IP地址及访问次数。 @@ -181,5 +215,5 @@ 答案: ```Shell - + cat /var/log/nginx/access.log|head -100000|awk -F" " '{print $1}' |sort|uniq -c|sort -nrt 2 -t|awk -F" " 'print $1' |head -1 ``` \ No newline at end of file -- Gitee From 09ea7408af79a1c9d1e37437b513a2b735a71215 Mon Sep 17 00:00:00 2001 From: Administrator <616697902@qq.com> Date: Mon, 14 Oct 2019 11:44:25 +0800 Subject: [PATCH 2/3] chy --- python-interview-2019-3.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python-interview-2019-3.md b/python-interview-2019-3.md index eb44d3f..0eb834e 100644 --- a/python-interview-2019-3.md +++ b/python-interview-2019-3.md @@ -17,6 +17,7 @@ 答案: ``` + ('abcd',(1,2,3,4,5)) {1:'item{1},2:'item{9}'} 5 @@ -177,11 +178,11 @@ 10. 请阐述访问一个用Django或Flask开发的Web应用,从用户在浏览器中输入网址回车到浏览器收到Web页面的整个过程中,到底发生了哪些事情,越详细越好。 - 答案: + 答案: - ``` + ``` - ``` + ``` 11. 请阐述HTTPS的工作原理以及TCP是如何保证端到端可靠传输的。 -- Gitee From e1b77d2b261203f819344de07450c0ed94aee784 Mon Sep 17 00:00:00 2001 From: Administrator <616697902@qq.com> Date: Mon, 14 Oct 2019 11:46:37 +0800 Subject: [PATCH 3/3] chy2 --- python-interview-2019-3.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python-interview-2019-3.md b/python-interview-2019-3.md index 0eb834e..e88f264 100644 --- a/python-interview-2019-3.md +++ b/python-interview-2019-3.md @@ -17,7 +17,6 @@ 答案: ``` - ('abcd',(1,2,3,4,5)) {1:'item{1},2:'item{9}'} 5 @@ -178,11 +177,11 @@ 10. 请阐述访问一个用Django或Flask开发的Web应用,从用户在浏览器中输入网址回车到浏览器收到Web页面的整个过程中,到底发生了哪些事情,越详细越好。 - 答案: + 答案: - ``` + ``` - ``` + ``` 11. 请阐述HTTPS的工作原理以及TCP是如何保证端到端可靠传输的。 -- Gitee