111
继续学习
0
f.flush
di si hang
3
kujing qian jia r
问答题:
0、不会,会以该名称创建一个文件
1、对文件对象使用flush()方法
2、表示从当前文件指针指向的字符开始,读取3个字符
3、一行,因为writelines对于迭代对象不会用换行符分开
4、print()函数使用时默认换行
5、文件的路径名中含有转移字符所用的'\'
6、调整文件指针位置?
7、可以
8、指出下一步操作的位置
9、end of file
10、利用tell()方法
动动手:
0、
>>> f = open('FishC.txt','r+')
>>> for i in range(9):
f.write(' ')
>>> f.truncate(15)
1、
f = open('FishC.txt','r+')
f.seek(15)
f.truncate()
f.close()
2、'''openself'''
f = open('open_myself.py','r+')
for i in f:
print(i,end = '')
3、
>>> f = open('test.jpg','a')
>>> f.writable()
True
>>> f.write('target.zip')
10
>>> f.close()
1
{:5_95:}
学习
查看参考答案
53
1
happy
沙发
0. 不会
1. flush
2.
3. 1行
4.
5.
6. 保存原有文件
7. 可以
8. 指向字符的位置
9. end of the file
10. tell
图一时之快
0.o
0. 会报错
1. 有,用.flush()
2. 代表从第4个字符开始读取
3. 一行
4. 留白
5. 留白
6. 得注意文档是否是空的,如果非空会将内容清空
7. 不可以,追加模式得先有文档
8. 文件指针的作用是告诉操作者当前的位置,以方便后续的操作
9. end of the file ,文档结束了,读完了
10. tell()方法可以知道指针位置
动手题:
0.
f = open("FishC.txt", "r+")
f.seek(10)
new_write = f.read(5)
fd = open("FishD.txt", "w")
fd.write(new_write)
fd.close()
1.
f = open("FishC.txt", "r+")
f.truncate(15)
f.close()
2.
def open_myself():
f = open("open_myself.py", "r")
print(f.read())
f.close()
open_myself()
3.
fj = open("test.jpg", "b")
fz = open("test.zip", "r+")
fj.write(fz.read())
fj.close()
2
349
查看答案