Python Learning (25)-OS. Path Module

Source: Internet
Author: User

Official documentation: Http://docs.python.org/library/ OS .path.html

Reprinted from: http://www.cnblogs.com/dkblog/archive/2011/03/25/1995537.html

OS. path. abspath (PATH) # returns the absolute path (_ file _ in the file) OS. path. basename (PATH) # returns the file name OS. path. commonprefix (list) # Return the longest paths in the list (multiple paths. OS. path. dirname (PATH) # returns the file path OS. path. exists (PATH) # True is returned if the path exists, and falseos is returned if the path is damaged. path. lexists # If the path exists, true is returned. If the path is damaged, trueos is returned. path. expanduser (PATH) # Put "~ "And "~ Convert user to user directory OS. path. expandvars (PATH) # Replace the "$ name" and "$ {name}" OS in the path based on the value of the environment variable. path. getatime (PATH) # returns the last time the path was entered. OS. Path. getmtime (PATH) # returns the last modification time under this path. OS. path. getctime (PATH) # returns the size of the path OS. path. getsize (PATH) # returns the file size. If the file does not exist, the system returns the error OS. path. isabs (PATH) # determine whether it is an absolute path OS. path. isfile (PATH) # determine whether the path is a file OS. path. isdir (PATH) # determine whether the path is a directory OS. path. islink (PATH) # determine whether the path is linked to the OS. path. ismount (PATH) # determine whether the path is a mount point () OS. path. join (path1 [, path2 [,...]) # combine the Directory and file name into a path OS. path. normcase (PATH) # convert the case and slash OS of the path. path. normpath (PATH) # standard path string form OS. path. realpath (PATH) # returns the real path OS of path. path. relpath (path [, start]) # Calculate the relative path OS from start. path. samefile (path1, path2) # determine whether the directory or file is the same as OS. path. sameopenfile (FP1, fp2) # determine whether FP1 and fp2 point to the same file OS. path. samestat (STAT1, stat2) # determine whether stat tuple STAT1 and stat2 point to the same file OS. path. split (PATH) # divide the path into dirname and basename, and return an OS. path. splitdrive (PATH) # It is generally used in windows and returns the OS, which consists of the drive name and path. path. splitext (PATH) # split the path, and the OS with the path name and file extension is returned. path. splitunc (PATH) # splits the path into a load point and a file OS. path. walk (path, visit, ARG) # traverse the path and call the visit function in each directory. The visit function must have three parameters (ARG, dirname, names ), dirname indicates the Directory Name of the current directory, names indicates all file names in the current directory, and ARGs indicates the third parameter OS of the walk. path. supports_unicode_filenames # Sets whether Unicode path names are supported

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.