使用 os.system() 到 运行 没有 root 的命令

using os.system() to run a command without root

我有一个 python 2 脚本,它是 运行 作为 root。我想在没有 root 权限的情况下使用 os.system("some bash command"),我该怎么做?

尝试在 os.system("some bash command") 之前使用 os.seteuid(some_user_id)

我已经在我的电脑上进行了测试。如果您 运行 像 'sudo test.py' 这样的 python 脚本,问题就解决了。