知识卡片

问题卡 · 6237.e

分页返回需要说明完成程度

理解等级:中级

循环可因数量达到上限、cursor耗尽或请求返回None而停止,但函数只返回两个ID列表,不附停止原因。调用者因此不能仅凭列表非空判断已收齐,空列表也可能是不可访问。应把目标上限、实际数量、终止原因和续传位置一起记录,按请求范围解释完整性。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      if len(ids) >= limit or response is None: break # Do something useful with the IDs, like store them to disk... return friends_ids[:friends_limit], followers_ids[:followers_limit] #

    参考来源

    - 位置:《社交网站的数据挖掘与分析(原书第2版)》第9章《9.19.3 讨论》(spine145;extracted/OReilly精品图书系列共21册(《Javascript权威指南》、《机器学习:实用案例解析》、《编写可读代码的艺术》、《算法精解》等)/_epub-src/text/part0134.html;u213-ch09-027)。 - 结论依据:原文在“if len(ids) >= limit or response is None”附近的定义、例子或代码支撑本卡核心说明:循环可因数量达到上限、cursor耗尽或请求返回None而停止,但函数只返回两个ID列表,不附停止原因。边界按已读前提解释;示例未执行。 - 原始内容:if len(ids) >= limit or response is None: break # Do something useful with the IDs, like store them to disk... return friends_ids[:friends_limit], followers_ids[:followers_limit] #