嗨,我正在使用psutil,我想要访问bytes_sent。
net = psutil.net_io_counters(pernic=True)输出=>
{'lo': iostat(bytes_sent=122424, bytes_recv=122424, packets_sent=1408, packets_recv=1408, errin=0, errout=0, dropin=0, dropout=0), 'kvnet': iostat(bytes_sent=3594694, bytes_recv=25226835, packets_sent=28971, packets_recv=29051, errin=0, errout=0, dropin=0, dropout=0), 'eth0': iostat(bytes_sent=5591347, bytes_recv=29589927, packets_sent=33000, packets_recv=46178, errin=0, errout=0, dropin=0, dropout=0)}当我这么做时:
sent = psutil.net_io_counters().bytes_sent()
receved = psutil.net_io_counters().bytes_recv()我犯了个错误
TypeError: 'int' object is not callable有什么问题吗?
发布于 2014-09-22 11:49:29
psutil.net_io_counters(pernic=True)返回一个包含所有接口统计信息的数据集。
为了获得单独的结果,您需要执行以下操作:
net = psutil.net_io_counters(pernic=True)
# Notice no brackets in the end
sent = net['lo'].bytes_sent
received = net['lo'].bytes_recv
# or with the eth0 interface
sent = net['eth0'].bytes_sent
received = net['eth0'].bytes_recv发布于 2020-08-20 03:00:05
去掉引号:-
psutil.net_io_counters().bytes_senthttps://stackoverflow.com/questions/25973005
复制相似问题