Share Python OS. system experiences

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.