Skip to content

Commit b74e0de

Browse files
committed
更新了部分文档补充了Linux部分的内容
1 parent 4082e1a commit b74e0de

14 files changed

+609
-177
lines changed

.DS_Store

-16 KB
Binary file not shown.

Day16-20/Python语言进阶.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
# 第二天A第一个醒来 他将鱼分为5份 扔掉多余的1条 拿走自己的一份
220220
# B第二个醒来 也将鱼分为5份 扔掉多余的1条 拿走自己的一份
221221
# 然后C、D、E依次醒来也按同样的方式分鱼 问他们至少捕了多少条鱼
222-
fish = 1
222+
fish = 6
223223
while True:
224224
total = fish
225225
enough = True
@@ -232,7 +232,7 @@
232232
if enough:
233233
print(fish)
234234
break
235-
fish += 1
235+
fish += 5
236236
```
237237

238238
贪婪法例子:假设小偷有一个背包,最多能装20公斤赃物,他闯入一户人家,发现如下表所示的物品。很显然,他不能把所有物品都装进背包,所以必须确定拿走哪些物品,留下哪些物品。
@@ -769,6 +769,8 @@
769769
main()
770770
```
771771

772+
> 说明:上面的代码中使用了Emoji字符来表示扑克牌的四种花色,在某些不支持Emoji字符的系统上可能无法显示。
773+
772774
- 对象的复制(深复制/深拷贝/深度克隆和浅复制/浅拷贝/影子克隆)
773775

774776
- 垃圾回收、循环引用和弱引用

Day16-20/code/[email protected]

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
多进程和进程池的使用
3+
多线程因为GIL的存在不能够发挥CPU的多核特性
4+
对于计算密集型任务应该考虑使用多进程
5+
time python3 example22.py
6+
real 0m11.512s
7+
user 0m39.319s
8+
sys 0m0.169s
9+
"""
10+
import concurrent.futures
11+
import math
12+
13+
PRIMES = [
14+
1116281,
15+
1297337,
16+
104395303,
17+
472882027,
18+
533000389,
19+
817504243,
20+
982451653,
21+
112272535095293,
22+
112582705942171,
23+
112272535095293,
24+
115280095190773,
25+
115797848077099,
26+
1099726899285419
27+
] * 5
28+
29+
30+
def is_prime(n):
31+
"""判断素数"""
32+
if n % 2 == 0:
33+
return False
34+
35+
sqrt_n = int(math.floor(math.sqrt(n)))
36+
for i in range(3, sqrt_n + 1, 2):
37+
if n % i == 0:
38+
return False
39+
return True
40+
41+
42+
def main():
43+
"""主函数"""
44+
with concurrent.futures.ProcessPoolExecutor() as executor:
45+
for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)):
46+
print('%d is prime: %s' % (number, prime))
47+
48+
49+
if __name__ == '__main__':
50+
main()

Day31-35/res/andrew-tanenbaum.png

-140 KB
Binary file not shown.

Day31-35/res/andrew.jpg

282 KB
Loading
File renamed without changes.
File renamed without changes.

Day31-35/res/ken_young.jpg

20.1 KB
Loading
File renamed without changes.

Day31-35/res/pdp-11.jpg

43.2 KB
Loading

Day31-35/res/rk05.jpg

25.2 KB
Loading

0 commit comments

Comments
 (0)