Python为udp打开多个cmd提示



我正在尝试运行一个python脚本,该脚本打开两个命令提示符,模拟udp的客户端和服务器。基本上,我想要这样的

os.system('cmd /k "python server.py"')
os.system('cmd /k "python client.py"')

我可以单独运行脚本来使其工作,但我希望用一个脚本来执行整个过程。

我建议您以以下方式使用线程:

import threading
import os
def server():
os.system("python server.py")
def client():
os.system("python client.py")
def main():
server_thread = threading.Thread(target=server)
server_thread.start()
client_thread = threading.Thread(target=client)
client_thread.start()

最新更新