Get file attributes (hidden, readonly, system, archive) in Python
问题 Just started learning Python. How can i get a status of file's attributes in Python? I know that os.chmod(fullname, stat.S_IWRITE) delete readonly attribute, but how can i get status without changing it? I need to get all of the attributes of "hidden" , "system" , "readonly" , "archive" 回答1: You can use directly the Windows API like that import win32con import win32api attrs = win32api.GetFileAttributes(filepath) attrs & win32con.FILE_ATTRIBUTE_SYSTEM attrs & win32con.FILE_ATTRIBUTE_HIDDEN