import psutil
import time
import tkinter
from PIL import Image, ImageTk
def network_state(): #实时流量
bytes_sent1 = psutil.net_io_counters(pernic=True)['WLAN'].bytes_sent
bytes_recv1 = psutil.net_io_counters(pernic=True)['WLAN'].bytes_recv
#print(bytes_sent1,bytes_recv1)
time.sleep(1)
bytes_sent2 = psutil.net_io_counters(pernic=True)['WLAN'].bytes_sent
bytes_recv2 = psutil.net_io_counters(pernic=True)['WLAN'].bytes_recv
sent_rate = bytes_sent2 - bytes_sent1
recv_rate = bytes_recv2 - bytes_recv1
if sent_rate < 1024 and recv_rate < 1024:
L1.configure(text=str(sent_
Python网络流量检测
最新推荐文章于 2025-06-24 15:27:11 发布