带有示例的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 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短