搜索
写经验 领红包
 > 时尚

python设置文件权限 答案全全给你奉上

1、os.chmod()方法 此方法通过数值模式更新路径或文件权限。该模式可采取下列值或按位或运算组合之一:

stat.s_isuid: set user id on execution.

stat.s_isgid: set group id on execution.

stat.s_enfmt: record locking enforced.

stat.s_isvtx: save text image after execution.

stat.s_iread: read by owner.

stat.s_iwrite: write by owner.

stat.s_iexec: execute by owner.

stat.s_irwxu: read, write, and execute by owner.

stat.s_irusr: read by owner.

stat.s_iwusr: write by owner.

stat.s_ixusr: execute by owner.

stat.s_irwxg: read, write, and execute by group.

stat.s_irgrp: read by group.

stat.s_iwgrp: write by group.

stat.s_ixgrp: execute by group.

stat.s_irwxo: read, write, and execute by others.

stat.s_iroth: read by others.

stat.s_iwoth: write by others.

stat.s_ixoth: execute by others.

2、语法:

os.chmod(path, mode);

3、参数:

path: this is the path for which mode would be set.

mode: this may take one of the above mentioned values or bitwise oredcombinations of them: