带有示例的Python文件错误属性
文件错误属性
errorsProperty是Python中File对象(IO对象)的内置属性,用于获取Unicode错误处理程序以及Unicode。
语法:
file_object.errors
Parameter(s):
没有
返回值:
该方法的返回类型为<class'str'>,它以字符串形式返回Unicode错误处理程序。
示例
#带有示例的Python文件错误属性
#以各种模式打开文件
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)
#关闭文件
file1.close()
file2.close()
file3.close()输出结果
file1.errors: strict file2.errors: strict file3.errors: ignore
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短