gpt4 book ai didi

windows - 属性错误 : 'module' object has no attribute 'testmod' Python doctest

转载 作者:可可西里 更新时间:2023-11-01 09:20:03 24 4
gpt4 key购买 nike

每当我尝试在 python 中进行 doctest 时,基本上每当我运行代码时

if __name__ =="__main__":
import doctest
doctest.testmod()

我从口译员那里得到了这个回应

AttributeError: 'module' 对象没有属性 'testmod'

我可以很好地运行这段代码,但是每当我在我的 Windows 机器上运行它时,它就无法运行。

我的机器运行的是 Windows 他们的是 OS X,但运行的是 python 2.7.5。

谢谢你:)

最佳答案

确保您没有尝试将测试文件保存为 doctest.py。上面建议的打印语句将显示它。如果文件名为doctest.py,则重命名并重试。

关于windows - 属性错误 : 'module' object has no attribute 'testmod' Python doctest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29089174/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com