Sobes.tech
Junior — Middle

Could you explain what a file in text form is?

sobes.tech AI

Answer from AI

A file in text format is a file that contains data in the form of a sequence of characters, usually encoded in a specific encoding (e.g., UTF-8 or ASCII). Such a file can be opened and read with any text editor because it does not contain binary data.

An example of a text file could be a source code file, a configuration file, or a simple notes document. Unlike binary files, text files are convenient for editing and viewing by humans.

In Python, working with text files is done using the open function with read or write mode:

with open('example.txt', 'r', encoding='utf-8') as file:
    content = file.read()
    print(content)