获取我的文档路径


import ctypes.wintypes
 
def getDocPath(pathID=5):
    '''path=5: My Documents'''
    buf= ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
    ctypes.windll.shell32.SHGetFolderPathW(None, pathID, None, 0, buf)
    return buf.value
 
for i in range(60):
    print(i,getDocPath(i))
 
print('\nMy Documents\' Path:',end='\n\t')
print(getDocPath())

评论
  目录