Python os.chflags () method definition and Usage introduction (instance parsing)

Source: Internet
Author: User
Let's look at this article today. python osThe. Chflags () method, in the following article we will introduce Python OS moduleThe Chflags () method describes its definition and its role and purpose.

Overview

The Os.chflags () method is used to set the tag of the path to a number tag. Multiple tags can be combined using OR.

Only supported for use under Unix.

Grammar

The syntax format for the Chflags () method is as follows:

Os.chflags (path, flags)

Parameters

Path--The file name path or directory path.

Flags--can be the following values:

Stat. Uf_nodump: Non-dump file

Stat. Uf_immutable: File is read-only

Stat. Uf_append: File can only append content

Stat. Uf_nounlink: File is not deleted

Stat. Uf_opaque: The directory is opaque and needs to be viewed through the federated stack

Stat. Sf_archived: Archived files (Super User-selectable)

Stat. Sf_immutable: File is read-only (super user selectable)

Stat. Sf_append: File can only append content (super User can set)

Stat. Sf_nounlink: File cannot be deleted (super User can set)

Stat. Sf_snapshot: Snapshot file (Super user selectable)

(The method has no return value.) )

Instance

The following example demonstrates the use of the Chflags () method:

#!/usr/bin/python#-*-coding:utf-8-*-import os,statpath = "/tmp/foo.txt" # Sets the tag for the file so that it cannot be renamed and deleted by flags = Stat. Sf_nounlinkretval = os.chflags (path, flags) print "Return value:%s"% retval

Execute the above program output as:

return value: None

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.