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

标签 windows macos python-2.7 doctest

每当我尝试在 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/

相关文章:

windows - Go 程序作为 Windows 服务

c++ - 从磁盘读取或分配系统内存哪个更快

python - 简明地说 "none of the elements of an array are None"?

python-2.7 - 在 groupby 数据框中应用唯一两次

winforms - 将 C#.NET 应用程序从 Windows 迁移到 OSX(Windows 窗体)

连续从串口接收可变数据的Python代码

c - 如何知道 WM_PAINT 是否必须删除背景?窗口API

windows - 在 Windows 或 Cygwin 中加速 Ruby 脚本启动

objective-c - 操作系统 : NSUserNotification - Displays old app icons.

linux - 汇编 Linux 系统调用与汇编 OS x 系统调用