Because all use os module
import os
First hit.
--Get the pathname of the current directory
path = os.getcwd()
print(path)
--Display folders and files in the current directory
ls = os.listdir(os.getcwd())
print(ls)
--Move directory
os.chdir ("Desctop") # This is all you need to move curdir = os.getcwd() print(curdir)
--Get the directory name of the current directory
curdirname = os.path.basename(os.getcwd())
print(curdirname)
Recommended Posts