Interview
1.列表去重,保持顺序
1 | a = [1, 3, 3, 60, 43, 630, 2, 1, 5] |
2. 列表中带有字典,按照字典的值排序
1 | a = [{'u': 2}, {'u': 1}, {'u': 3}] |
3. 单例模式
1 | class Singleton(object): |
1 | def singleton(cls): |
4. 什么情况下会出现StackOverflow
- 递归过深可能会导致StackOverflow,比如设置
sys.setrecursionlimit(1)
,可以导致这个结果出现
什么是Stack, Heap
闭包
装饰器,什么样的语言可以实现装饰器
__init__和__new__的区别
- __new__是类方法, __init__是实例方法
- __new__会返回一个创建的实例,__init__不返回任何东西
- 由__new__创建cls的实例后,__init__才能被调用
HTTP, TCP/IP 分别在四层模型和七层模型的第几层,TCP/UDP的区别
HTTP状态码的具体含义
202 Accepted, 401 Unauthorized, 403 Forbidden, 405 Method Not Allowed, 502 Bad Gateway, 504 Gateway Timeout
401 Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. 401 semantically means “unauthenticated”. i.e. the user does not have the necessary credentials.
403 The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource, or may need an account of some sort.
HTTP Header里有哪些信息
- 通用首部 Connection, Date, MIME-Version, Trailer, Transfer-Encoding, Update, Via, Accept, Authorization, Cookie
- 请求首部 From, Host, Referer, User-Agent
- 响应首部 Age, Public, Warning, Server
- 实体首部 Allow, Content-Length, Content-Type, Last-Modified
cookie和session的区别
- cookie存在客户端,session在服务端,session需要cookie来实现
Python2和Python3中的字符串有什么区别
1 | # python2 |
async/await模型
Python的多线程,多进程,GIL分别使用的场景
进程通信
Python的传值方式
- 可变对象是引用传递,不可变对象是值传递