Skip to content

Commit 818a284

Browse files
iamthecloverlytechyminati
authored andcommitted
Copy Content of One File to Another in Python
1 parent a28e26c commit 818a284

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

copy_file.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
print("Enter the Name of Source File: ")
2+
sFile = input()
3+
print("Enter the Name of Target File: ")
4+
tFile = input()
5+
6+
fileHandle = open(sFile, "r")
7+
texts = fileHandle.readlines()
8+
fileHandle.close()
9+
10+
fileHandle = open(tFile, "w")
11+
for s in texts:
12+
fileHandle.write(s)
13+
fileHandle.close()
14+
15+
print("\nFile Copied Successfully!")

0 commit comments

Comments
 (0)