python 使用 adduser --home linux

Use of adduser --home linux by python

我需要在 python 中创建一个具有主目录的用户。目前,我正在这样做:

adduser --home /test testing

但是,这也需要一些输入。我如何执行这样的命令并在 python 中提供输入?

输入的是密码、房间号等

谢谢

您可以使用 useradd 而不是 adduser 您可以指定密码和 more via in CLI (I guess you are or should use subprocess)

以后请注意按照 SO guideline first search for similar questions before asking a new question. For example the answer to your question can be found here