2024-10-06 07:54:48 发布
网友
嗨,我的问题是python读取ubuntu14.10x64位中发送和接收的字节
我在osx中的功能代码是:
#Network net = psutil.net_io_counters(pernic=True) sent = humanize.naturalsize(net['en0'].bytes_sent) received = humanize.naturalsize(net['en0'].bytes_recv) print(sent) print(received)
谢谢
您正在硬编码接口名称,但ubuntu使用不同的命名方案。在我的机器上
>>> psutil.net_io_counters(pernic=True).keys() ['lo', 'virbr0', 'eth1', 'eth0'] >>>
…我的活动接口是'eth1'
'eth1'
您正在硬编码接口名称,但ubuntu使用不同的命名方案。在我的机器上
…我的活动接口是
'eth1'
相关问题 更多 >
编程相关推荐