这是我的代码的一部分:
import os
def _get_appdata_path():
import ctypes
from ctypes import wintypes, windll
CSIDL_APPDATA = 26
_SHGetFolderPath = windll.shell32.SHGetFolderPathW
_SHGetFolderPath.argtypes = [wintypes.HWND,
ctypes.c_int,
wintypes.HANDLE,
wintypes.DWORD,
wintypes.LPCWSTR]
path_buf = wintypes.create_unicode_buffer(wintypes.MAX_PATH)
result = _SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, path_buf)
return path_buf.value
但是当我调用 wintypes.create_unicode_buffer()
时,我得到了错误:
AttributeError: module 'ctypes.wintypes' has no attribute 'create_unicode_buffer'
我正在使用 Python 3.5.1。我能做什么?
最佳答案
使用 ctypes.create_unicode_buffer,它在 PY2 和 PY3 中都有效。由于使用 from ctypes import *
,它只是在 PY2 的 wintypes 中意外出现。 :D
关于python - 属性错误 : module 'ctypes.wintypes' has no attribute 'create_unicode_buffer' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40084734/