Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 调用命令,然后写入相同的子进程_Python_Subprocess - Fatal编程技术网

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(“密码”)
。它正在执行命令,但等待密码输入,但是使用此写入方法不会将任何内容写入命令窗口。我想要的解决方案是能够运行命令,然后在同一命令窗口中键入,这样我就可以输入密码。

这篇文章应该可以帮助您: