如何使用python启动和比较来自windows/console程序的一些信息?
自从我上次“玩”python 以来已经有很长一段时间了,最近我需要用它做一些事情,但我不记得太多了,即使需要导入库...你们能给我一个吗手?
我会给你一个例子,它不是我需要的完全比较,但它会像它一样工作......
例如,我需要比较从具有不同包大小的 ping 接收到的一些数据。
这是交易: 我希望我的程序启动到 192.168.1.1 的 ping 命令,参数 -l(缓冲区大小)从 0 到 100,然后比较女巫是高还是低......
像这样:
ping 192.168.1.1 -l 1
1ms
ping 192.168.1.1 -l 2
1ms
ping 192.168.1.1 -l 3
2ms
等等,因此,当它达到 -l 100 时,它会向我提供更高 ping(或更低)的参数,如下所示:
higher ping: 2ms (-l 3)
谢谢您的帮助。
It's been a long time since my last "play" with python, and recently I need to do something with it but I don't remember to much about it, even with libs are needed to import... Could you guys give me a hand?
I will give you an example, its not the exactly comparison that I need, but it will work just like it...
For example, I need to compare some data received from a ping with different packages sizes.
Here is the deal:
I want my program to launch the ping command to 192.168.1.1 with the arguments -l (buffer size) from 0 to, lets say, 100, and compare witch is high, or lower...
Something like this:
ping 192.168.1.1 -l 1
1ms
ping 192.168.1.1 -l 2
1ms
ping 192.168.1.1 -l 3
2ms
and so on, so when it reaches -l 100, it gives me the argument with the higher ping (or lower), something like this:
higher ping: 2ms (-l 3)
Thank you for helping.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 subprocess.check_output 并解析其输出 http://docs.python.org/library /subprocess.html#subprocess.check_output 。根据文档:
例如
Use subprocess.check_output and parse its output http://docs.python.org/library/subprocess.html#subprocess.check_output . Per the docs :
E.g.