permission change of files in python

前端 未结 3 606
陌清茗
陌清茗 2021-02-13 10:35

I want to change the file permission for all the files from my current directory tree. I am trying to open each directory and open the files and change the permission using

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-13 11:37

    You are using os.walk incorrectly.

    for dirpath, dirnames, filenames in os.walk('.'):
        for filename in filenames:
            path = os.path.join(dirpath, filename)
            os.chmod(path, 0o777) # for example
    

提交回复
热议问题