python_interview_question icon indicating copy to clipboard operation
python_interview_question copied to clipboard

关于python的面试题

Results 22 python_interview_question issues
Sort by recently updated
recently updated
newest added

```python class APP: _instance = None def __new__(cls, *args, **kwargs): print("new") if cls._instance is None: print("Create") cls._instance = super().__new__(cls, *args, **kwargs) return cls._instance def __init__(self): print("init") self.prop = None app...

原题 72.map(lambda x:xx,[y for y in range(3)])的输出? 应该更新为 72.map(lambda x:x*x,[y for y in range(3)])的输出? 结果为 [0,1,4]

file.read([size]) 从文件读取指定的字节数(size),如果未给定或为负则读取所有。 file.readline([size])读取整行,包括 "\n" 字符。 file.readlines([sizeint]) 读取所有行并返回列表,若给定sizeint>0,则是设置一次读多少字节,这是为了减轻读取压力。

``` def get_lines(): l = [] with open('test/1.py','rb') as f: data = f.readlines(60000) l.append(data) yield l ``` ## 上面代码yield l结束是否只能读取文件6万行,可能读取不到文件末尾 ## 下面是我的代码 ``` def my_get_lines(num_lines=1): with open(r'test/1.py', 'r', encoding="utf-8") as...

Number: a. 整型 int、 **长整型 long**、浮点型 float、 复数 complex Number 不包含长整型long 包含bool

保持源代码不动的情况,while循环第一个if后加个else赋值? else: d[target-nums[size]] = nums[size]

使用`Python3`提供的`Pathlib`包操作 ```python def print_directory_contents(s_path): from pathlib import (Path, PosixPath) origin_path = Path(s_path) if not isinstance(s_path, PosixPath) else s_path for s_child in origin_path.iterdir(): if not s_child.is_dir(): print(s_child) continue print_directory_contents(s_child)

``` import threading class Singleton(object): _instance_lock = threading.Lock() def __new__(cls, *args, **kwargs): if not hasattr(cls, '_instance'): with Singleton._instance_lock: if not hasattr(cls, '_instance'): cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs) return cls._instance...

经典的谬误之一 ** 4.GET方式提交的数据最多只能有1024字节,而POST则没有限制 安全性问题,正如在(2)中提到,使用GET的时候,参数会显示在地址栏上,而POST不会** 可能并不知道 ES 的 Query 查询是把请求体写在 Get 的 body 中的? 建议读一下 [RFC 2616](https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3)