licaixa
发表于 2023-10-29 10:16:15
111
swj520qll
发表于 2023-10-29 15:43:37
继续学习
happyduck
发表于 2023-10-30 09:28:28
0
f.flush
di si hang
3
kujing qian jia r
淡水酸菜鱼
发表于 2023-10-31 16:36:16
问答题:
0、不会,会以该名称创建一个文件
1、对文件对象使用flush()方法
2、表示从当前文件指针指向的字符开始,读取3个字符
3、一行,因为writelines对于迭代对象不会用换行符分开
4、print()函数使用时默认换行
5、文件的路径名中含有转移字符所用的'\'
6、调整文件指针位置?
7、可以
8、指出下一步操作的位置
9、end of file
10、利用tell()方法
yangxu_sky
发表于 2023-10-31 16:38:40
淡水酸菜鱼
发表于 2023-10-31 17:02:15
动动手:
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()
忆故我在
发表于 2023-11-1 01:33:41
1
树上那只羊
发表于 2023-11-1 14:14:11
{:5_95:}
luxd6880
发表于 2023-11-1 14:59:44
学习
孙花花
发表于 2023-11-1 15:00:29
查看参考答案
adsl9999
发表于 2023-11-5 14:13:41
53
sxt18357237208
发表于 2023-11-7 15:06:10
1
PossibleWL
发表于 2023-11-8 11:01:26
happy
coolrookie
发表于 2023-11-9 14:04:48
沙发
东瓜_34
发表于 2023-11-9 23:04:08
0. 不会
1. flush
2.
3. 1行
4.
5.
6. 保存原有文件
7. 可以
8. 指向字符的位置
9. end of the file
10. tell
灾祸之火
发表于 2023-11-10 11:56:47
图一时之快
Anonymous
发表于 2023-11-11 08:58:31
0.o
Num.67167
发表于 2023-11-13 10:47:55
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()
黄一丹
发表于 2023-11-13 19:29:57
2
349
liming1240
发表于 2023-11-13 21:33:24
查看答案