doctest模块

最后更新于:2022-04-02 02:17:18

[TOC] ## doctest模块 import doctest def average(values): """Computes the arithmetic mean of a list of numbers. >>> print(average([20, 30, 70])) 40.0 """ return sum(values) / len(values) doctest.testmod() # 自动验证嵌入测试 >强化文档,允许 doctest 模块确认代码的结果是否与文档一致:
';