Access denied from "shutil.rmtree('dir_path')", despite emptying dir_path's contents

Viewed 17

The function "shutil.rmtree('dir_path') " does remove the content of the folder, however, it also throw the exception as follow "[WinError 5] Access is denied: 'dir_path'"

from shutil import rmtree
my_folder = 'aaa/bbb/'
try:
    rmtree(my_folder)
except Exception as err:
    print (err)
0 Answers
Related