Python. IOError: [Errno 13] Permission denied: when i'm copying file

后端 未结 9 1323
轮回少年
轮回少年 2021-01-03 19:44

I have two folders: In, Out - it is not system folder on disk D: - Windows 7. Out contain \"myfile.txt\" I run the following command in python:

>>>          


        
9条回答
  •  走了就别回头了
    2021-01-03 19:57

    First of all, make sure that your files aren't locked by Windows, some applications, like MS Office, locks the oppened files.

    I got erro 13 when i was is trying to rename a long file list in a directory, but Python was trying to rename some folders that was at the same path of my files. So, if you are not using shutil library, check if it is a directory or file!

    import os
    path="abc.txt"
    
    if os.path.isfile(path):
        #do yor copy here
        print("\nIt is a normal file") 
    

    Or

    if os.path.isdir(path):
        print("It is a directory!")
    else:
        #do yor copy here
        print("It is a file!")
    

提交回复
热议问题