Computer Science
Differentiate between text file and binary file.
Python File Handling
8 Likes
Answer
Text File | Binary File |
---|---|
A text file consists of human readable characters, which can be opened by any text editor. | A binary file is made up of non-human readable characters and symbols, which require specific programs to access its contents. |
A text file is a file that stores information in the form of a stream of ASCII or Unicode characters. | A binary file is a file that stores the information in the form of a stream of bytes. |
In text files, each line of text is terminated with a special character known as EOL (End of Line) character. | In a binary file, there is no delimiter for a line and no character translations occur here. |
Files with extensions like .txt, .py, .csv etc are some examples of text files. | Files with extensions like .jpg, .pdf etc are some examples of binary files. |
Answered By
6 Likes
Related Questions
Differentiate between readline() and readlines().
Differentiate between write() and writelines().
Write the use and syntax for the following methods:
- open()
- read()
- seek()
- dump()
Write the file mode that will be used for opening the following files. Also, write the Python statements to open the following files:
- a text file “example.txt” in both read and write mode.
- a binary file “bfile.dat” in write mode.
- a text file “try.txt” in append and read mode.
- a binary file “btry.dat” in read only mode.