Overview:
- The method reconfigures the encoding scheme, new line characters, error handling mechanism for encoding errors, buffering and write-through options of a TextIOWrapper object.
Example:
Without the reconfigure method writing using ASCII and unicode_escape would have been not easy. This Python program would have reported an error stating "UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)" if the encoding was not changed to "unicode_escape" while writing the Japanese version of the "Hello World".
|
# Example Python program that reconfigures # Open a text file and obtain a TextIOWrapper instance # Multiple lines in diffrent encodings # Write using ASCII # Write using "UTF-8" f.seek(0) |
Output:
|
Hello World こんにちは世界 |