通过os.chdir()更改目录后,os.system(“ dir”)无法正常工作

时间:2019-08-08 07:09:24

标签: python windows shell cmd python-os

问题

通过os.system("dir")更改目录后,

os.chdir()无法正常工作

代码

os.system("dir") # Works here
print(os.getcwd())
os.chdir("..")
print(os.getcwd())
os.system("dir") # Does not works here

输出

C:\Folder1\Folder2
Volume in drive C is Windows_OS
Volume Serial Number is 0000-0000

Directory of C:\Folder1\Folder2

08/08/2019  12:14 PM    <DIR>          .
08/08/2019  12:14 PM    <DIR>          ..
08/08/2019  12:14 PM    <DIR>          Files.txt

C:\Folder1
The system cannot find the path specified.

0 个答案:

没有答案