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/ Explanation:

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad