摘要: Python 使用 yield 关键字来创建生成器。生成器相比列表具有使用内存小、可流式处理等优势。 使用 yield: def process_file(file): with open(file) as f: for line in f: yield process_line(line) # 对 阅读全文
posted @ 2025-04-14 17:53 Undefined443 阅读(12) 评论(0) 推荐(0)