Copying contents of one file into another file in Python
File handling in Python
try:
with open("myfile.txt", "r") as f1:
with open("newfile.txt", "w") as f2:
for i in f1:
# print(type(f2))
f2.write(i)
except:
print("Sorry! The file does not exist. Plz create first.")
else:
print("Contents of file copied successfully.")
Comments
Post a Comment
Write something to CodeWithAbdur!