Python 22nd Day Stat Module Os.chmod method Os.stat method

Source: Internet
Author: User
Tags posix

Python 22nd Day Stat Module Os.chmod method Os.stat method

The stat module describes the meaning of the values in the list of file attributes returned by Os.stat (filename), reading the values in Os.stat () according to the stat module
In short, Os.stat is to read the relevant properties of the file and then use the Stat module to process

Os.stat

Returns a stat result with the result type Posix.stat_result

Stat Result (PATH)

Get stat Results

st = Os.stat ('/tmp/aa.py')print  stposix.stat_result (St_mode =33188, st_ino=385537, st_dev=64513l, St_nlink=1, St_uid=0, St_gid=0, st_size=1243, st_atime=1505466749, st_mtime= 1505870370, st_ctime=1505870370) type (ST) Posix.stat_result

Os.chmod () method

The Os.chmod () method is used to change the permissions of a file or directory.
Grammar
The chmod () method syntax is formatted as follows, and the method does not return a value:
Os.chmod (path, mode)


Parameters
Path--The file name path or directory path.
Flags-The following options can be used for bitwise OR permission overlays.


Stat. S_ixoth: Other users have executive rights 0o001
Stat. S_iwoth: Other users have write permission 0o002
Stat. S_iroth: Other users have Read permission 0o004
Stat. S_irwxo: Other users have full permissions (permission mask) 0o007
Stat. S_IXGRP: Group user has execute permission 0o010
Stat. S_IWGRP: Group user has write permission 0o020
Stat. S_IRGRP: Group user has Read permission 0o040
Stat. S_IRWXG: Group user has full permissions (permission mask) 0o070
Stat. S_IXUSR: Owner has execute permission 0o100
Stat. S_IWUSR: Owner has write permission 0o200
Stat. S_IRUSR: Owner has Read permission 0o400
Stat. S_irwxu: Owner has full permissions (permission mask) 0o700
Stat. S_ISVTX: The file directory in the directory only the owner can delete the changes 0o1000
Stat. S_isgid: Execute this file its process valid group is the file group 0o2000
Stat. S_isuid: Execute this file whose process is valid for the user as the file owner 0o4000
Stat. S_iread:windows under Read-only
Stat. S_iwrite:windows Cancel Read-only

Python 22nd Day Stat Module Os.chmod method Os.stat method

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.