码迷,mamicode.com
首页 > 编程语言 > 详细

python修改文件的属性

时间:2018-03-01 14:53:02      阅读:1299      评论:0      收藏:0      [点我收藏+]

标签:nbsp   body   dep   test   读文件   drive   系统文件   blog   python2   

1、执行attrib系统命令

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I]
[drive:][path][filename] [/S [/D] [/L]]
+ 设置属性。
- 清除属性。
R 只读文件属性。
A 存档文件属性。
S 系统文件属性。
H 隐藏文件属性。
I 无内容索引文件属性。
[drive:][path][filename]
指定 attrib 要处理的文件。
/S 处理当前文件夹及其所有子文件夹中的匹配文件。
/D 也处理文件夹。
/L 处理符号链接和符号链接目标的属性。

example:os.system(‘attrib -h d:\yy‘)

2:os.chmod

import stat,os
def TestForChangeToWrite(path):
   # This is platform indepedent.     
   if not os.access(path,os.W_OK):
        os.chmod(path,stat.S_IWRITE)
TestForChangeToWrite("c:\\python26\\python.exe")

 

python修改文件的属性

标签:nbsp   body   dep   test   读文件   drive   系统文件   blog   python2   

原文地址:https://www.cnblogs.com/lcamry/p/8488043.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!