Test directory permissions in Python?

前端 未结 3 1326
北荒
北荒 2020-12-07 01:44

In Python on Windows, is there a way to determine if a user has permission to access a directory? I\'ve taken a look at os.access but it gives false results.

3条回答
  •  离开以前
    2020-12-07 02:15

    Actually 'C:\haveaccess' is different than r'C:\haveaccess'. From Python point of view 'C:\haveaccess' is not a valid path, so use 'C:\\haveaccess' instead. I think os.access works just fine.

提交回复
热议问题