在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python  網(wǎng)絡(luò)安全/ Python2.7執(zhí)行print()函數(shù)發(fā)生IOError錯(cuò)誤

Python2.7執(zhí)行print()函數(shù)發(fā)生IOError錯(cuò)誤

我要編寫一個(gè)腳本,控制瀏覽器,如果當(dāng)前已經(jīng)運(yùn)行了超過兩秒鐘就關(guān)閉,但是在執(zhí)行的過程中執(zhí)行到print函數(shù)時(shí)就會(huì)發(fā)生IOError: [Errno 0] Error的錯(cuò)誤,代碼和錯(cuò)誤如下圖
圖片描述

代碼單獨(dú)粘出來

#coding:utf-8
from pydbg import *
import os
import copy
import time

def check_timeout():#防止非加載時(shí)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()

請(qǐng)表哥們幫幫忙!!

回答
編輯回答
苦妄

python 2.7里print是語句:

print "hello world"

python 3.x里print是函數(shù):

print("hello world")
2017年12月22日 08:27