2016-10-17 4 views
0

더 속성 'create_unicode_buffer'가 없습니다 :AttributeError는 : 모듈 'ctypes.wintypes는'이것은 내 코드의 일부이다

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' 

I을 Python 3.5.1을 사용하고 있습니다. 내가 뭘 할 수 있니?

+2

http://stackoverflow.com/questions/626796/how-do-i-find-the-windows-common-application-data-folder-using-python#comment33587651_626927 – gplayer

답변

3

PY2 및 PY3에서 모두 작동하는 ctypes.create_unicode_buffer를 사용하십시오. from ctypes import *의 사용으로 인해 PY2의 wintypes에서만 실수로 발생했습니다. D

관련 문제