小白教程
所有教程
关于
Search
172.69.58.243
172.69.58.243
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 os chroot”的源代码
本页内容
上一节:
Python3_os_chown
下一节:
Python3_os_close
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:os.chroot(path)}}[[Category:python3 os file methods|6]] = Python3 os.chroot() 方法 = [[python3 os file methods|Python3 OS 文件/目录方法]] === 概述 === os.chroot() 方法用于更改当前进程的根目录为指定的目录,使用该函数需要管理员权限。 在 unix 中有效。 === 语法 === '''chroot()'''方法语法格式如下: <sample title="" desc="" lang="python" hererun="1"> os.chroot(path); </sample> === 参数 === * '''path''' -- 要设置为根目录的目录。 === 返回值 === 该方法没有返回值。 == 以下实例演示了 chroot() 方法的使用: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 import os, sys # 设置根目录为 /tmp os.chroot("/tmp") print ("修改根目录成功!!") </sample> 执行以上程序输出结果为: <sample title="" desc="" lang="python" hererun="1"> 修改根目录成功!! </sample> [[python3 os file methods|Python3 OS 文件/目录方法]]
返回至“
Python3 os chroot
”。
上一节:
Python3_os_chown
下一节:
Python3_os_close