我正在尝试在 Windows 机器上使用 wexpect,并在非常基本的操作中遇到问题。我正在运行以下命令:
import wexpect
child = wexpect.spawn('cmd.exe')
child.send('dir')
并收到以下错误:
C:\Users\Administrator\PycharmProjects\testProject\venv\Scripts\python.exe
C:/Users/Administrator/PycharmProjects/testProject/test.py
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/testProject/test.py", line 3, in <module>
child.send('dir')
File "C:\Users\Administrator\PycharmProjects\testProject\venv\lib\site-packages\wexpect.py", line
1810, in send
c = self.wtty.write(s)
File "C:\Users\Administrator\PycharmProjects\testProject\venv\lib\site-packages\wexpect.py", line
2128, in write
wrote = self.__consin.WriteConsoleInput(records)
**pywintypes.error: (6, 'WriteConsoleInput', 'The handle is invalid.')**
Process finished with exit code 1
请指教