python chmod_Python os.chmod用法及代码示例

python chmod_Python os.chmod用法及代码示例Python中的os.chmod()方法用于将路径模式更改为数字模式。用法:os.chmod(path,mode)参数:path-pathnameofthefileordirectorypathmode-modemaytakeoneofthefollowingvalues:stat.S_ISUID:SetuserIDonexecutionstat.S…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

Python中的os.chmod()方法用于将路径模式更改为数字模式。

用法:

os.chmod(path, mode)

参数:

path – path name of the file or directory path

mode – modemay take one of the following values:

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

代码1:

# Python program to explain os.chmod() method

# importing necessary libraries

import os, sys, stat

# Set given file read by the owner.

os.chmod(“/Geeks/gfg.txt”, stat.S_IREAD)

print(“File can be read only by owner.”)

# Set given file read by others.

os.chmod(“/Geeks/gfg.txt”, stat.S_IROTH)

print(“File access changed, can be read by others now.”)

输出:

File can be read only by owner.

File access changed, can be read by others now.

代码2:

# Python program to explain os.chmod() method

# importing necessary libraries

import os, sys, stat

# Set given file written by the owner.

os.chmod(“/Geeks/gfg.txt”, stat.S_IWRITE)

# Set given file executed by the owner.

os.chmod(“/Geeks/gfg.txt”, stat.S_IXUSR)

print(“File can be written and executed only by owner.”)

输出:

File can be written and executed only by owner.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/179869.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • MySQL常见的数据类型[通俗易懂]

       不多说,直接上干货!       MySQL常见的数据类型一、数据类型是什么?  数据类型是指列、存储过程参数、表达式和局部变量的数据特征,它决定了数据的存储格式,代表了不同的信息类型。  有一些数据是要存储为数字的,数字当中有些是要存储为整数、小数、日期型等… 二、MYSQL常见数据类型  MySQL支持多种类型,大致可以…

    2022年4月5日
    44
  • vue富文本编辑器插件推荐_vue富文本编辑器的使用

    vue富文本编辑器插件推荐_vue富文本编辑器的使用vue富文本编辑器,插件

    2022年10月14日
    2
  • visdom API 方便使用查阅

    visdom API 方便使用查阅代码Structure如下:1、基础Visdom提供以下基本的可视化功能:vis.image:图片 vis.images:图像列表 vis.text:任意的HTML vis.video:视频 vis.svg:SVG对象 vis.save:序列化状态服务器端2、绘制我们已经封装了几种常见的绘图类型,以便轻松创建基本可视化。这些可视化由Plotly提供支持。目前支持…

    2022年6月17日
    39
  • php漏洞 乌云,GitHub – grt1st/wooyun_search: 乌云公开漏洞、知识库搜索 search from wooyun.org…

    php漏洞 乌云,GitHub – grt1st/wooyun_search: 乌云公开漏洞、知识库搜索 search from wooyun.org…wooyun_search乌云公开漏洞、知识库搜索0x00.介绍灵感来源于hanc00l的github项目wooyun_publicwooyun_public基于flask或者tornado,而本项目可以布置在apache、nginx等web服务器上。如果你有wooyun的静态网页数据,那么我们可以开始了!整个项目包括两个部分,第一部分是索引,将网页信息存储进数据库;第二部分是搜索,从数据库中查找…

    2025年6月8日
    3
  • VS2015中用C++创建MFC DLL动态库「建议收藏」

    VS2015中用C++创建MFC DLL动态库「建议收藏」1打开VS2015,新建MFCdll动态库,如下图所示:2点击下一步,在应用程序设置里选择带静态链接的MFC规则,这个主要为了以静态库的形式生成MFCdll,便于动态库可以移植到其它编程语言或者其它计算机系统里调用。3将编译模式改为Release模式4以上步骤就将MFCdll动态库的编译环境配置好了。接下来开始编译动态库导出的函数。在MFC_dll.cpp中写入函数的……

    2022年9月30日
    3
  • Idea激活码最新教程2023.1.6版本,永久有效激活码,亲测可用,记得收藏

    Idea激活码最新教程2023.1.6版本,永久有效激活码,亲测可用,记得收藏Idea 激活码教程永久有效 2023 1 6 激活码教程 Windows 版永久激活 持续更新 Idea 激活码 2023 1 6 成功激活

    2025年5月27日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号