×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Home » Python

Python File errors Property with Example

Python File errors Property: Here, we are going to learn about the errors Property, how to get the Unicode error handler from the file object in Python?
Submitted by IncludeHelp, on December 24, 2019

File errors Property

errors Property is an inbuilt property of File object (IO object) in Python, it is used to get the Unicode error handler along with the Unicode.

Syntax:

    file_object.errors

Parameter(s):

  • None

Return value:

The return type of this method is <class 'str'>, it returns the Unicode error handler as a string.

Example:

# Python File errors Property with Example

# opening files in various modes
file1 = open("myfile1.txt", "w")
file2 = open("myfile3.txt", "a")
file3 = open("myfile3.txt", "w", errors='ignore')

print("file1.errors: ", file1.errors)
print("file2.errors: ", file2.errors)
print("file3.errors: ", file3.errors)

# closing the files
file1.close()
file2.close()
file3.close()

Output

file1.errors:  strict
file2.errors:  strict
file3.errors:  ignore
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.