Red de conocimiento informático - Problemas con los teléfonos móviles - copiar archivos de Python

copiar archivos de Python

Utilice Python para copiar archivos de un directorio a un directorio específico. El código es el siguiente:

1. Primero inserte las bibliotecas necesarias: import?os?

<. p>import?os.path?

import?shutil?

import?time,?datetime

2. :

def?copyFiles(sourceDir, targetDir):?

if?sourceDir.find(".svn")? gt;?0:?

return

for?

sourceFile = os.path.join(sourceDir, archivo)?

targetFile?=?os.path.join(targetDir, archivo )?

if?os.path.isfile(sourceFile):?

if?not?os.path.exists(targetDir):?

os .makedirs(targetDir): ?

si?no?os.path.exists(targetFile)?o(os.path.exists(targetFile)?y?(os.path.getsize(targetFile)? ! =?os.path .getsize(sourceFile)):?

open(targetFile, "wb").write(open(sourceFile, "rb").read())?

if?os .path.isdir(archivoorigen):?

¿Primer_directorio?=?False?

copiar archivos(archivoorigen,?archivodestino)

3 Implementación de la función principal: if?__name___?=="__main__":?

print?"Start(S)?or?Quilt(Q)?\n"?

¿bandera?

¿respuesta?=?raw_input()?

si?

bandera=?

formatTime?=?getCurTime( )?

targetFoldername?=?" targetFoldername?Build?"? ¿Debug_File_Path, Target_File_Path)?

P>

¿QuitarFileInfirs (target_file_path)?

Coverfiles (Release_file_path, target_path)?

¿Moverfileto (Firebird_file_Path, Target_f iLe_Path)? p>

¿Mover archivo a (assistantgui_file_path, target_file_path)?

escribirVersionInfo(Target_File_

¿Ruta "\\ReadMe.txt")?

¿imprimir?"todo?éxito"?

otro:?

imprimir?"no es el comando correcto " ?