Python File copy

 # File handling 

# File copy


fs = None

fd = None


try:

fs = open("Src.txt","r")

fd = open("Dest.txt","w")

except IOError as e:

print("File opening error : ", e)

except:

print("unknown error")

else:

fdata = fs.read()

fd.write(fdata)

print("File copied sucessfully!!!")

finally:

if(fs):

fs.close()

if(fd):

fd.close()

"""

Sample output


Input file: Src.txt

Hello!!!

Welcome!!!

IT

CSE

EEE

ECE

Welcome!!!

Python


>python FileCopy.py

File copied sucessfully!!!



Output file: Dest.txt

Hello!!!

Welcome!!!

IT

CSE

EEE

ECE

Welcome!!!

Python


"""

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu