The OS module of the Python module is detailed

Source: Internet
Author: User

Os.listdir (dirname): Lists directories and files under DirName os.getcwd (): Get current working directory Os.curdir: Returns the current directory ('. ') Os.chdir (dirname): Change the working directory to Dirnameos.path.isdir (name): Determine if Name is a directory, name is not a directory and return Falseos.path.isfile (name): Determine if name is a file, does not exist name also returns Falseos.path.exists (name): Determine if there is a file or directory Nameos.path.getsize (name): Get the file size, If name is the directory return 0los.path.abspath (name): Gets the absolute path Os.path.normpath (path): Canonical path string form Os.path.split (name): Split file name and directory (in fact, If you use the directory completely, it will also separate the last directory as the file name, and it will not determine if the file or directory exists) Os.path.splitext (): Detach the filename with the extension os.path.join (path,name): Connection directory with file name or directory Os.path.basename (PATH): Returns the file name Os.path.dirname (path): Returns the path Os.remove (dir) #dir为要删除的文件夹或者文件路径os. RmDir ( Path) #path要删除的目录的路径. It should be explained that the directory deleted using Os.rmdir must be an empty directory, or the function will fail. Os.path.getmtime (name) # Gets the file's modified time Os.stat (path). st_mtime# Gets the modified time of the file Os.stat (path). St_ctime # Gets the file modification time Os.path.getctime (name) #获取文件的创建时间

The OS module of the Python module is detailed

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.