Python module os.chmod(file, 664) does not change the permission to rw-rw-r— but -w--wx----

前端 未结 6 950
轮回少年
轮回少年 2020-12-13 01:42

Recently I am using Python module os, when I tried to change the permission of a file, I did not get the expected result. For example, I intended to change the permission to

6条回答
  •  时光说笑
    2020-12-13 02:32

    If you have desired permissions saved to string then do

    s = '660'
    os.chmod(file_path, int(s, base=8))
    

提交回复
热议问题