How to calculate network usage with Python on Windows 7?
How would I go about writing a p开发者_如何学Pythonython script that shows how much bandwidth is being used and how much data is being transferred on a Windows 7 machine?
What you want technically isn't a problem of the language you're using - how much data is being transferred on your network interfaces is something you need to get from your operating system or network device driver. The way that you acquire these statistics will vary based on the OS, so that's what you need to nail down first.
I found a nice utility called PSUtil. Performing the call:psutil.network_io_counters(pernic=False)
you will be able to get the total system network usage. You can then parse the string it returns to get the actual data.
Firstly, it depends on which version of Python you are currently using. If your using v2.6.5, you might want to check here.
精彩评论