Python 到 Windows 命令提示字元介面

Python 到 Windows 命令提示字元介面

有沒有辦法將命令傳送到 Windows 命令提示字元 Python?

我想做的是在桌面上創建一個 Python 應用程序,它透過套接字從另一台電腦/行動應用程式接收命令。

然後這些命令將傳遞到 Windows 命令提示字元以執行。

使用Windows 7。

答案1

使用子流程模組

from subprocess import call

call(['cmd', 'arg1', 'arg2'], stdin='...', stdout='...')

例如:

call(['dir', '/W'])

在這裡閱讀更多內容子流程管理

相關內容