Question
Explain how file handling works in Python for text files. Mention different file modes, and a short description of read(), readline() and write().
Answer :
Word Count : 298
________ _________ _____ __________ _______ _________ ________ ___.
______ __________ _________ _______ ______ _________.
_____ ___ ___ _____ _____ ____ ______ ___ ___ ______ _____ _____.
___ ____ ______ ___ ______.
_____ ______ _____ ____ _________ _________ ________ ______ ___ _____ ______ ______.
_____ ______ _____ ____ ____ ____ ________ __________ ______.
_______ _______ ____ __________ _______ ____ _____.
_______ ___ ________ ________ ___ ________ ______ _____ _____ ________.
_________ _____ ______ ____ ___ ____ ___ _______ ____ _____.
__________ _______ _________ _______ ___ ___ ________ _________ _________ _____ _______.
______ __________ __________ _______ __________ __________ _____ ____ _________.
___ ________ ________ _________ __________.
_________ _______ _________ _________ __________.
_________ ________ ______ ________ ____ _______ __________ __________.
_______ ____ __________ _______ ________ ______ __________.
________ _________ ___ _____ _______ ____ _________ _____.
__________ ____ ___ __________ ________ ______ ___ ______ ___ _________ __________ ______.
_________ _________ ___ ______ _____ _________.
_______ ________ ______ __________ _____ ___ ______ _____ _______ _______ ____ ___.
____ ____ ___ ________ _______ ____ _____ __________ _______ ______ ____.
____ _____ _____ _______ __________ _________ ___ _____ _________ ___ _________.
______ _____ _____ _____ ________ _________ _______ ____ ______.
_________ __________ _______ _________ ______ ______ ________ ___.
Skip in 10
In Python, file handling allows programs to create, read, update, and delete files. To work with a text file, the `open()` function is used, which returns a file object. The basic syntax is `file = open(filename, mode)`, where `filename` is the name of the file, and `mode` specifies the operation to be performed on the file. Common file modes include `'r'` for reading, `'w'` for writing (creates a new file or truncates an existing file), `'a'` for appending (adds data at the end of the file),
__________ __________ _________ __________ ___ ____ ________ ________ ______ ____ _________.________ _________ _____ __________ _______ _________ ________ ___.
______ __________ _________ _______ ______ _________.
_____ ___ ___ _____ _____ ____ ______ ___ ___ ______ _____ _____.
___ ____ ______ ___ ______.
_____ ______ _____ ____ _________ _________ ________ ______ ___ _____ ______ ______.
_____ ______ _____ ____ ____ ____ ________ __________ ______.
_______ _______ ____ __________ _______ ____ _____.
_______ ___ ________ ________ ___ ________ ______ _____ _____ ________.
_________ _____ ______ ____ ___ ____ ___ _______ ____ _____.
__________ _______ _________ _______ ___ ___ ________ _________ _________ _____ _______.
______ __________ __________ _______ __________ __________ _____ ____ _________.
___ ________ ________ _________ __________.
_________ _______ _________ _________ __________.
_________ ________ ______ ________ ____ _______ __________ __________.
_______ ____ __________ _______ ________ ______ __________.
________ _________ ___ _____ _______ ____ _________ _____.
__________ ____ ___ __________ ________ ______ ___ ______ ___ _________ __________ ______.
_________ _________ ___ ______ _____ _________.
_______ ________ ______ __________ _____ ___ ______ _____ _______ _______ ____ ___.
____ ____ ___ ________ _______ ____ _____ __________ _______ ______ ____.
____ _____ _____ _______ __________ _________ ___ _____ _________ ___ _________.
______ _____ _____ _____ ________ _________ _______ ____ ______.
_________ __________ _______ _________ ______ ______ ________ ___.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.