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