File Handling and read-write in Python ? How to use of read(), write(), delete() ?
File Handling Anonymous User 1346 06 Jul 2018 File Handling and read-write in Python ?How to use of read(), write(), delete() ?
File Handling:
All web application are having a important part its called File Handling. Python has several functions for creating,reading,updating, deleting files.
Syntax :
f = open("demofile.txt")Example :
f = open("demofile.txt", "r")print(f.read())
Write to an Existing File:
f = open("demofile.txt", "w")
f.write("Woops! I have deleted the content!")
Create a New File:
f = open("myfile.txt", "x")Delete a File using os.remove() function: