Programming Examples

Python program to marge the content of target file into source file


Write a Python program to accept two file name (source and Target) and copy and append the content of target file into source file.

Solution

fname1=input("Enter the Source File Name : ")
fname2=input("Enter the Target File Name : ")
fp1=open(fname1,"a")
fp2=open(fname2,"r")
data=fp2.read()
fp1.write(data)
fp1.close()
fp2.close()
Output

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad