import osmystr=os.popen("tasklist") #popen与system可以执行指令,popen可以接受返回对象mystr=mystr.read() #读取输出print("hello",mystr)if mystr.find("QQ.exe") !=-1: print("发现QQ")else: print("QQ已死有事请烧纸")
Python Windows 执行cmd命令 popen

最新推荐文章于 2024-04-16 20:51:49 发布

import osmystr=os.popen("tasklist") #popen与system可以执行指令,popen可以接受返回对象mystr=mystr.read() #读取输出print("hello",mystr)if mystr.find("QQ.exe") !=-1: print("发现QQ")else: print("QQ已死有事请烧纸")