- Files are opened using the built-in open() function which accepts a file mode to control read/write/append behaviour and whether the file is to be treated as raw binary or encoded text data.
- For text data you should specify a text encoding.
- Text files deal with string objects and perform universal newline translation and string encoding.
- Binary files deal with bytes objects with no newline translation or encoding.
- When writing files, it's your responsibility to provide newline characters for line breaks.
- Files should always be closed after use.
- Files provide various line-oriented methods for reading, and are also iterators which yield line by line.
- Files are context managers and the with-statement can be used with context managers to ensure that clean up operations, such as closing files, are performed.
- The notion of file-like objects is loosely defined, but very...
United States
Great Britain
India
Germany
France
Canada
Russia
Spain
Brazil
Australia
Singapore
Hungary
Philippines
Mexico
Thailand
Ukraine
Luxembourg
Estonia
Lithuania
Norway
Chile
South Korea
Ecuador
Colombia
Taiwan
Switzerland
Indonesia
Cyprus
Denmark
Finland
Poland
Malta
Czechia
New Zealand
Austria
Turkey
Sweden
Italy
Egypt
Belgium
Portugal
Slovenia
Ireland
Romania
Greece
Argentina
Malaysia
South Africa
Netherlands
Bulgaria
Latvia
Japan
Slovakia