>>> 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