Python os.chroot() 方法

Python 教程 · 2019-02-03 18:12:49

概述

os.chroot() 方法用于更改当前进程的根目录为指定的目录,使用该函数需要管理员权限。

语法

chroot()方法语法格式如下:

os.chroot(path);

参数

  • path -- 要设置为根目录的目录。

返回值

该方法没有返回值。

实例

以下实例演示了 chroot() 方法的使用:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, sys

# 设置根目录为 /tmp

os.chroot("/tmp")

print "修改根目录成功!!"

执行以上程序输出结果为:

修改根目录成功!!

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

Scalability Rules

Scalability Rules

Martin L. Abbott、Michael T. Fisher / Addison-Wesley Professional / 2011-5-15 / USD 29.99

"Once again, Abbott and Fisher provide a book that I'll be giving to our engineers. It's an essential read for anyone dealing with scaling an online business." --Chris Lalonde, VP, Technical Operatio......一起来看看 《Scalability Rules》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具