如何启动子程序并使用python 3向其写入命令

问题描述 投票:0回答:2

此代码启动记事本,但不写入其中...

导入子过程

self.process = subprocess.Popen('C:\ Windows \ System32 \ Notepad.exe',shell = True,stdin = subprocess.PIPE,stdout = subprocess.PIPE,stderr = subprocess.PIPE,cwd = None,env =无)

self.process.stdin.write('Hi \ n'.encode())

python subprocess stdin popen
2个回答
-1
投票

您可能需要像pyautogui这样的软件包才能在记事本中写入窗口。使用stdin仅适用于基于终端的应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.