|
|
请回复您的答案^_^
-------- 问答题 --------
第 0 题的答案是:
0、若带有2个入参,且第二个入参为w或者w+或者a\a+,则不会报错,否则报错
第 1 题的答案是:
1、flush()方法
第 2 题的答案是:
2、读取3个字符
第 3 题的答案是:
3、一行字符串
第 4 题的答案是:
4、因为读取换行符 单独显示出来
第 5 题的答案是:
5、因为反斜杠\ 把后面跟随的字母转义,获取文件句柄错误
第 6 题的答案是:
6、使用w,打开会把文件内容截断
第 7 题的答案是:
7、可以
第 8 题的答案是:
8、标识在文件中的位置
第 9 题的答案是:
9、文件内容结束符
第 10 题的答案是:
10、seek()
-------- 动动手 --------
请将第 0 题的代码写在下方:
f1 = open(f"D:\python_study\FishC.txt", "r")
f2 = open(f"D:\python_study\FishD.txt", "w")
f1.seek(10)
f2.writelines(f1.readline(5))
f1.close()
f2.close()
请将第 1 题的代码写在下方:
f1 = open(f"D:\python_study\FishC.txt", "r+")
f1.seek(15)
f1.truncate()
f1.close()
请将第 2 题的代码写在下方:
f_myfile = open(f"D:\python_study\open_myself.py", "r", encoding="utf-8")
for line in f_myfile:
print(line)
f_myfile.close()
请将第 3 题的代码写在下方:
f_test = open(r"D:\python_study\hw\test.jpg", "ab+")
f_yc_file = open(r"D:\python_study\hw\target.zip", "rb")
f_test.seek(0, 2)
f_test.write(f_yc_file.read())
f_yc_file.close()
f_test.close() |
|