Python 3.x 如果存在';it’后面有一个STDIN

Python 3.x 如果存在';it’后面有一个STDIN,python-3.x,subprocess,stdout,popen,sqlmap,Python 3.x,Subprocess,Stdout,Popen,Sqlmap,在尝试将sqlmap与我的自动化工具集成时,当尝试运行命令并将输出保存到文件中时,控制台上不会打印需要用户输入的行;它将在参数传递后打印。要求在两个位置(终端和输出文件)上打印控制台输出。由于sqlmap在执行过程中需要用户的输入,因此无法使用子流程。请检查\u output() 代码段: [try: cmd = cmd.rstrip() process = subprocess.Popen(cmd,shell=True,stdout=subpr

在尝试将sqlmap与我的自动化工具集成时,当尝试运行命令并将输出保存到文件中时,控制台上不会打印需要用户输入的行;它将在参数传递后打印。要求在两个位置(终端和输出文件)上打印控制台输出。由于sqlmap在执行过程中需要用户的输入,因此无法使用
子流程。请检查\u output()

代码段:

[try:
            cmd = cmd.rstrip()
            process = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
                while True:
                    out = process.stdout.readline()\[0:\]
                    if out == '' and process.poll() is not None:
                            break
                    if out:
                            output += out                           
                            print(out.strip())

        except Exception as e:
            exception_message = str(e)
            output += exception_message
            if 'exit status 1' not in exception_message:
                self.utilities.print_color("\[!\] Error executing the command: " + cmd,'red')
            output += '\r\n'

        print(output)
        return output][1]

可能是以下缩进问题:
如果输出:
,您应该缩进
输出+=out
,下一行谢谢您的评论,缩进没有问题。当我复制粘贴代码时,这是一个问题。编辑了代码段和描述。