I remember the lastArticlePython popen is written in. If you use Python popen to process some system commands, it returns an object,
For example:
Import OS
Print OS. popen ('Ping g.cn ')
It returns a file object. You can perform operations on this file object.
But if you want to see the running result directly, you need to usePython OS. SystemAfter it is used, it will be immediate!
Or the above problem:
Import OS
Print OS. System ('Ping g.cn ')
The output result is:
64 bytes from 203.208.37.99: icmp_seq = 0 TTL = 245 time = 36.798 MS
64 bytes from 203.208.37.99: icmp_seq = 1 TTL = 245 time = 37.161 MS
In fact, the result of this output is the same as that of running Ping g.cn on the console, except that the python OS module is used.
If you are interested, you can use Python OS. system to try more system commands to implement more functions.
Author: Lao Wang @Python Python tutorial
Old Wang Python provides Python-relatedPython books,Python host, Django tutorial andPython downloadHope you will like it!