在Python中,使用0777模式的`os.makedirs()`不会给予其他人写入权限

在Python中使用0777模式的os.makedirs()创建的目录无法给予其他人写入权限。问题在于权限位可能被umask关闭。解决方法是先调用os.umask(0)以确保提供的模式能完全生效。
摘要由CSDN通过智能技术生成

In Python, os.makedirs() with 0777 mode can not give others write permission

Python中 ,使用0777模式的os.makedirs()无法给予其他人写入权限

The code is as follows

代码如下

$ python
Python 2.7.5 (default, Aug  4 2017, 00:39:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.makedirs("/tmp/test1/test2", 0777)
>>> 

The created dirs are not having permiss

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值