1
我需要使用修補程序目錄中提供的文件更新現有目錄。 這就是我開始。所有評論都由我發表,然後我嘗試構建每一行。查找,重命名和替換文件
# $SourceDirectory = Patch folder that has files in any number of sub folders
# $DestDirectory = Application folder that has the files that need patching
# $UnMatchedFilesFolder = A Folder where SourceFiles go that don't have a match in $DestDirectory
# import os.path
# import os.listdir
#
# Create list1 of files from $SourceDirectory
# For each file (excluding directory names) in List1 (including subfolders), search for it in $DestDirectory and its subfolders;
# If you find the file by the same name, then create a backup of that file with .old;
# move $DestDirectoryPathAndFile to $DestDirectoryPathAndFile.old;
# print "Creating backup of file";
# After the backup is made, then copy the file from the $SourceDirectory to the;
# exact same location where it was found in the $DestDirectory. ;
# Else;
# move file to UnmatchedFilesDirectory.;
# If the number of files in $UnMatchedFilesDirectory =/ 0;
# Create list3 from $UnmatchedFilesDirectory
# print "The following files in $UnMatchedFilesDirectory will need to be installed individually";
# Print "Automated Patching completed.";
# Print "Script completed";
這看起來像僞代碼,而不是Python的?可能想要編輯它,以清楚它意味着什麼是評論和什麼不是。如果2周後您無法分辨僞代碼和真實代碼的差異,那麼這個課程就浪費您的時間。 –
你有什麼嘗試?你能給我們提供你寫的代碼的例子,它打破了什麼,你期望的是什麼?我們都可以爲你編寫代碼,但如果你正在嘗試學習python,那不會太有用。 –
是的,這是我剛剛手寫的psuedo代碼,可以獲得一些粗略的想法。它決不是形式或形式是真實的代碼。我睡了一小會兒,現在我要再來一次。敬請關注。 –