Home > Net >  I am trying to import a file using import os but it's keeps saying directory not empty
I am trying to import a file using import os but it's keeps saying directory not empty

Time:12-24

Import os
source="/storage/emulated/0/converted.py"
destination="/storage/emulated/0/DCIM"
try:
    if os.path.exists(destination):
        print("file already there")
    if os.replace(source,destination):
        print(source  " was moved")
except FileNotFoundError:
    print(source  " file was not found")
    

After trying import a file to another I get an error "directory not empty" I am new to coding so I am bit confused,should the destination be empty before importing? and lastly I sometimes get an error saying "not a directory" and I was just wondering if I can only transfer files from directory to directory alone? or can transfer from both(directory and folder)? Thanks in advance for your answer❤️

  • Related