

It ends the current line and tells the interpreter a new one has begun.Ī backslash character can also be used, and it tells the interpreter that the next character – following the slash – should be treated as a new line. There are several types, but the most common is the comma or newline character. This is what you know as code or syntax.Įach line is terminated with a special character, called the EOL or End of Line character.

Text files are structured as a sequence of lines, where each line includes a sequence of characters. Most files are organized by keeping them in individual folders.Ī file In Python is categorized as either text or binary, and the difference between the two file types is important. That means files can be images, text documents, executables, and excel file and much more. In Windows, for example, a file can be any item manipulated, edited or created by the user/OS. What you may know as a file is slightly different in Python. You must understand that a fileand file objectare two wholly separate – yet related – things.

And the nameattribute tells you the name of the file. They can also be used to manipulate said file.įor example, the modeattribute of a file object tells you which mode a file was opened in. File objects contain methods and attributes that can be used to collect information about the file you opened. When you use the openfunction, it returns something called a file object.
