OS. path and pythonos. path in the python Module

Source: Internet
Author: User

OS. path and pythonos. path in the python Module

Operations on the file path

 

The OS. path. split (p) function returns the directory name and file name of a path.

OS. path. splitext (): separates file names and extensions

 

The OS. path. isfile () and OS. path. isdir () functions verify whether the given path is a file or a directory.

OS. path. isabs (path): determines whether a path is an absolute path.

The OS. path. exists () function is used to check whether the GIVEN path actually exists.

 

OS. path. getsize (name): Get the file size. If the name is a directory, return 0L

OS. path. getatime (path) returns the last access time of the file or directory pointed to by path.

OS. path. getmtime (path) returns the last modification time of the file or directory pointed to by path.

 

OS. path. normpath (path): standard path string format

>>> OS. path. normpath ('C: // windows \ System32 \ ../Temp /')

'C: \ windows \ Temp'

OS. path. join (path, name): Connection directory and file name or directory

 

OS. path. basename (path): returns the file name.

OS. path. dirname (path) returns the path directory. It is actually the first element of OS. path. split (path ).

OS. path. abspath (path) returns the absolute path of path normalization.

>>> Import OS. path

>>> OS. path. abspath ('C. py ')

'/Root/py/c. py'

>>> OS. path. abspath ('../py/c. py ')

'/Root/py/c. py'

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.