フォルダを再作成するスクリプトがあります:
# Remove folder (if exists) with all files
if os.path.isdir(str(os.path.realpath('..') + "\\my_folder")):
shutil.rmtree(os.path.realpath('..') + "\\my_folder", ignore_errors=True)
# Create new folder
os.mkdir(os.path.realpath('..') + "\\my_folder")
これはほとんど常に機能しますが、場合によっては(作成ステップで)取得します
WindowsError: [Error 5] Access is denied: 'C:\\Path\\To\\my_folder'
このエラーの原因と回避方法を教えてください。