pythonioerror_Python2.7执行print()函数发生IOError错误

该脚本使用pydbg库监控Firefox进程,每隔两秒检查一次,如果发现进程状态没有变化,则关闭Firefox。在执行过程中遇到print语句时出现IOError: [Errno 0] Error。问题可能与输出操作有关。
摘要由CSDN通过智能技术生成

我要编写一个脚本,控制浏览器,如果当前已经运行了超过两秒钟就关闭,但是在执行的过程中执行到print函数时就会发生IOError: [Errno 0] Error的错误,代码和错误如下图

bV0Tzn?w=967&h=1080

代码单独粘出来

#coding:utf-8

from pydbg import *

import os

import copy

import time

def check_timeout():#防止非加载时timeout

dbg1 = pydbg()

now_status = []

while(True):

print("------------------------------------------")

last_status = copy.deepcopy(now_status)

print("last status:" + str(last_status))

now_status = []

for (pid,name) in dbg1.enumerate_processes():

if(name == "firefox.exe"):

now_status.append(pid)

time.sleep(2)

print("now status:" + str(now_status))

if(now_status==last_status):

if(now_status ==[]):

print("now_status enpty")

else:

print("last is the same as now ,kill firefox")

os.popen("taskkill /PID firefox.exe /f")

else:

print("last status is different from now status")

def main():

check_timeout()

if __name__ == '__main__':

main()

请表哥们帮帮忙!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值