Close

Python – Navigation directories

If you want to do pwd, cd, and ls, then you need to import the os module first:

[python]
import os
[/python]

Now we have the following functions:

[python]
=>=>=> os.getcwd() # equivalent to pwd
'C:\\users\\mir'
=>=>=> os.chdir("C:/") # equivalent to cd
=>=>=> os.listdir() # equivalent to ls
['$AVG', '$Recycle.Bin', 'Documents and Settings', 'hiberfil.sys', 'inetpub', 'Intel', 'NV
IDIA', 'pagefile.sys', 'PerfLogs', 'Prey', 'Program Files', 'Program Files (x86)', 'Progra
mData', 'Python34', 'Recovery', 'System Volume Information', 'Temp', 'Users', 'Windows']
=>=>=>
[/python]