Import Os.pathpath = '/home/vamei/doc/file.txt ' Print (os.path.basename (path)) # The file name that is contained in the query path print ( Os.path.dirname (Path) # The directory contained in the query path info = os.path.split # divides the path into a file name and a directory of two parts, placed in a table to return print (info) path2 = Os.path.join ('/', ' home ', ' Vamei ', ' Doc ', ' file1.txt ') # Use directory name and file name to form a path string, string concatenation output:/home\vamei\doc\file1.txtp_ list = [path, Path2]print (Os.path.commonprefix (p_list) #) # Queries the common part of multiple paths Os.path.normpath (path) # To remove redundancy from path paths. Like '/home/vamei/. /.' Converted to '/home ' print (os.path.exists) # query file for print (os.path.getsize path) # query file size print ( Os.path.getatime (path) # query file last read time print (Os.path.getmtime (path)) # query file last modified time print (Os.path.isfile ( Path) # paths are pointing to the regular file print (os.path.isdir) # Path is pointing to the directory file