os

python Path dependent functions
os.listdir(dirname):List the directories and files under dirname

os.getcwd():Get current working directory

os.curdir:Returns the current directory (“.”).

os.chdir(dirname):Change work directory to dirname

os.path.isdir(name):Determine whether name is a directory, and name is not a directory to return to false.

os.path.isfile(name):Judge whether name is a file, does not exist name, and returns to false?

os.path.exists(name):Determining whether there is a file or directory name

os.path.getsize(name):Get file size, if name is directory return 0

os.path.abspath(name):Get absolute path

os.path.normpath(path):Specification of path string format

os.path.split(name):Split the filename and directory (in fact, if you use the directory entirely, it also separates the last directory as the filename, and it does not determine whether the file or directory exists)

os.path.splitext():Separating filenames and extensions

os.path.join(path,name):Connect directory and file name or directory

os.path.basename(path):Return filename

os.path.dirname(path):Return file path

Leave a Reply

Your email address will not be published. Required fields are marked *