【问题标题】:Python os.st_uid only return value 0Python os.st_uid 只返回值 0
【发布时间】:2018-05-13 09:37:26
【问题描述】:

我正在使用 windows 机器和 python 3。我正在尝试从 windows 文件中获取用户 ID:

import os
os.stat('filepath').st_uid

但是,这只会返回 st_uid = 0,这是没有意义的。

有人可以帮忙吗?如果我不能使用st_uid,我还能用什么来获取文件用户信息?

谢谢!


更新:感谢您的帮助。我最终使用 Windows 安全 API 来获取用户信息:

Here is the link

【问题讨论】:

标签: python windows python-3.x


【解决方案1】:

Windows 上的os.stat() 似乎非常有限:os.stat() on Windows

所以 id 值被归零:你不能用它来获取用户 id 信息。

但是这个问答给出了大多数在 python 中的方法:Howto determine file owner on windows using python without pywin32

注意:这是一个 CW 答案,因为该问题实际上并不是任何一个链接答案的重复,但这个答案只是链接了两个方面:问题和解决方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-21
    • 2016-08-24
    • 1970-01-01
    • 1970-01-01
    • 2017-01-01
    相关资源
    最近更新 更多