【发布时间】:2015-03-07 21:25:29
【问题描述】:
想问问有没有人和我一样的问题,有没有解决办法。
当我在安装 Windows 7(64 位)之前使用 Windows XP(32 位)时,我在 Python 2.7.8 中使用了以下程序,没有任何错误:
from ctypes import *
kernel = windll.kernel32
...
当我在当前版本的操作系统上运行此序列时,出现错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'windll' is not defined
有人能知道这个错误的根本原因在哪里以及如何解决这个问题吗?
【问题讨论】:
-
only
import ctypes; print ctypes; print ctypes.windll显示什么? -
>>> import ctypes工作正常(没有错误)>>> print ctypes <module 'ctypes' from '/usr/lib/python2.7/ctypes/__init__.pyc'>也似乎工作正常>>> print ctypes.windll Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'windll' -
抱歉,我的意思是只有这 3 行的脚本,而不是单独的每一行 -- 包含这 3 行的脚本会显示什么?
-
出现如下错误:
➤ python test_ctypes.py <module 'ctypes' from '/usr/lib/python2.7/ctypes/__init__.pyc'> Traceback (most recent call last): File "test_ctypes.py", line 4, in <module> print ctypes.windll AttributeError: 'module' object has no attribute 'windll' -
我尝试在 cmd.exe 下运行它 - 没有任何问题。看来根本原因在mobaxterm。
标签: python python-2.7 ctypes