The default path for Python under Ws-dos is the default open path for Ws-dos cmd

Source: Internet
Author: User

>>> import os>>> os.getcwd () ' d:\\pythoncode\\pp4e ' >>> os.chdir (' Streams ') >>> OS.GETCWD () ' D:\\pythoncode\\pp4e\\streams ' >>> open (' hell_out.py '). Read () Traceback (most recent call last):  file "<stdin>", line 1, in <module>filenotfounderror: [Errno 2] No such File or directory: ' hell_out.py ' & Gt;>> open (' hello_out.py '). Read () "Print (' Hello Shell World ')" >>> pipe = Os.popen (' Python3 hello_out.py ') >>> python3:can ' t open file ' hello_out.py ': [Errno 2] No such file or directory>>> pipe = Os.popen (R ' Python3. \streams\hello_out.py ')    # Description Python's default path is ' d:\\pythoncode\\pp4e ' >>> pipe.read () ' Hello Shell World\n '

Default path for MS-DOS:

You can modify the default path for MS-DOS:

To modify the default path:

Test again:

D:\pythoncode\pp4e\streams>python3python 3.4.3 (v3.4.3:9b73f1c3e601, Feb, 22:44:40) [MSC v.1600 bit (AMD64) ] on Win32type ' help ', ' copyright ', ' credits ' or ' license ' for more information.>>> import os>>> os.getc WD () ' D:\\pythoncode\\pp4e\\streams ' >>> open (' hello_out.py '). Read () "Print (' Hello Shell World ')" >> > pipe = Os.popen (' Python3 hello_out.py ') >>> pipe.read () ' Hello Shell world\n ' >>> pipe.close ()

The default path for Python under Ws-dos is the default open path for Ws-dos cmd

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.