带有示例的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 新房祝福语简短10字
14 长辈新年祝福语大全简短
15 新年给大家简短祝福语
16 生日祝福语简短独特姑姑
17 芭比的婚礼祝福语简短
18 邀请新人祝福语简短英文