The Os.path of the Python module

Source: Internet
Author: User

Os.path.abspath (PATH) #返回绝对路径

Os.path.basename (PATH) #返回文件名

Os.path.commonprefix (list) #返回list (multiple paths), the longest path common to all paths.

Os.path.dirname (path) #返回文件所在路径 (directory)

Os.path.exists (path) #路径存在则返回True, path corruption returns false

Os.path.lexists #路径存在则返回True, path corruption also returns true

Os.path.expanduser (path) #把path中包含的 "~" and "~user" to the user directory

Os.path.expandvars (path) #根据环境变量的值替换path中包含的 "$name" and "${name}"

Os.path.getatime (Path) #返回最后一次进入此path的时间.

Os.path.getmtime (Path) #返回在此path下最后一次修改的时间.

Os.path.getctime (PATH) #返回path的大小

Os.path.getsize (path) #返回文件大小, returns an error if the file does not exist

Os.path.isabs (PATH) #判断是否为绝对路径

Os.path.isfile (PATH) #判断路径是否为文件

Os.path.isdir (PATH) #判断路径是否为目录

Os.path.islink (PATH) #判断路径是否为链接

Os.path.ismount (Path) #判断路径是否为挂载点 ()

Os.path.join (path1[, path2[, ...]) #把目录和文件名合成一个路径

Os.path.normcase (PATH) #转换path的大小写和斜杠

Os.path.normpath (PATH) #规范path字符串形式

Os.path.realpath (PATH) #返回path的真实路径

Os.path.relpath (path[, start]) #从start开始计算相对路径

Os.path.samefile (path1, path2) #判断目录或文件是否相同

Os.path.sameopenfile (FP1, FP2) #判断fp1和fp2是否指向同一文件

Os.path.samestat (STAT1, STAT2) #判断stat tuple STAT1 and Stat2 point to the same file

Os.path.split (path) #把路径分割成dirname和basename, returns a tuple

Os.path.splitdrive (path) #一般用在windows下, returns a tuple of drive names and paths

Os.path.splitext (path) #分割路径, returns a tuple of pathname and file name extension

Os.path.splitunc (PATH) #把路径分割为加载点与文件

Os.path.walk (path, visit, Arg) #遍历path, the visit function is called into each directory, and the visit function must have

3 parameters (ARG, dirname, names), dirname represents the directory name of the current directory, names represents all of the current directory

File name, args is the third parameter of walk

Os.path.supports_unicode_filenames #设置是否支持unicode路径名



This article from "Flat Light is true" blog, please be sure to keep this source http://ucode.blog.51cto.com/10837891/1763672

The Os.path of the Python module

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.