Python 调用命令,然后写入相同的子进程
我目前拥有以下代码:Python 调用命令,然后写入相同的子进程,python,subprocess,Python,Subprocess,我目前拥有以下代码: def run_commands(commands): commands = commands.split() process = subprocess.run(commands) process.stdin.write("password") output = run_commands("git clone ssh://git@git.com/opt/git/repository.git") 此代码可用于process.stdin.write(
def run_commands(commands):
commands = commands.split()
process = subprocess.run(commands)
process.stdin.write("password")
output = run_commands("git clone ssh://git@git.com/opt/git/repository.git")
此代码可用于process.stdin.write(“密码”)
。它正在执行命令,但等待密码输入,但是使用此写入方法不会将任何内容写入命令窗口。我想要的解决方案是能够运行命令,然后在同一命令窗口中键入,这样我就可以输入密码。这篇文章应该可以帮助您: