import os import shutil src = '.\\Objects\\Pro_App\\BLE_Chat.axf' dst = '..\\output\\聊天.axf' elf = '..\\elf_reduce.exe' if not os.path.exists(src): print(src+' File Error!!!') else: if os.path.exists(dst): os.remove(dst) if os.path.exists(elf): os.system(elf + ' ' + src + ' ' + dst) else: shutil.copy(src,dst) os.remove(src) print(dst+' File copy success.')