Python 字符串拼接用 join 而不是加号
"".join(list) 比 str += str 快很多因为字符串不可变每次 += 创建新字符串 O(n^2)。join 预分配缓冲区一次性生成。本文对比 10 万次拼接的性能差异。
30
0
0
2026-07-06