鑫xx
发表于 2023-10-7 22:37:43
0.不会
1.f.flush()
2.读取3行
3.1行
4.不懂
5.有转义字符
6.注意光标在哪里
7.可以
8.从哪里开始write
9.EOF
10.tell()
Jean88
发表于 2023-10-7 23:45:21
0
suyas9445
发表于 2023-10-9 21:03:05
0. r會報錯,但是w不會,會開一個新檔案
1.flush
2.只讀三個字符
3.一行
4.
5.
6.檔案是否已經存在
7.可以
8.指定輸入位置
9.end o the file
10. file.tell
0.
c = open("FishC.txt", "r")
c.seek(10)
s = c.readline(5)
d = open("./FishD.txt", "w")
d.write(s)
c.close()
d.close()
1.
c = open("FishC.txt", "r")
s = c.readline(15)
c.close()
c = open("FishC.txt", "w")
c.write(s)
c.close()
2.
f = open("FishC.txt", "r")
print(f.read())
3.
沈家伟
发表于 2023-10-9 23:51:07
(0)不会,会产生一个异常
(1)flush()
(2)读取三个字符
(3)一行
(4)print() 函数默认是会在末尾添加一个换行符
(5)因为路径中存在转义字符,导致文件路径解析错误。
(6)该文件十五已存在
(7)可以
(8)指示文件对象当前读取或者写入的位置。
(9)文件末尾
(10)tell()
(0)
Lin敏儿
发表于 2023-10-11 10:40:06
11
一次芳
发表于 2023-10-13 16:18:39
呀~
Vivivvvi
发表于 2023-10-14 10:00:57
0.会创建一个文件,存在于python主文件目录下
1.使用flush()将文件对象中的缓存内容存入文件中,不一定有效
2.读取3个字符
3.1行。需要自己换行
4.当for语句作用于文件对象时,是按行进行迭代的,也就是说讲文件中每一行内容读取到each变量中。print()默认会在末尾添加一个换行符
5.因为路径中存在转义字符
6.如果该文件存在,原文件内的内容会被清空
7.可以,如果指定文件存在,使用‘a'不会清空文件,而是在末尾追加
8.指定文件对象当前写入或者读取的位置
9.End of File,文件对象末尾的位置
10.用tell()追踪文件指针当前的位置,f.tell()可以返回当前文件指针的位置
0.f = open("FishC.txt","r")
fp = open("Writein.txt","w")
text = f.split('')
fp = f.writelines(text)
2.f = open("open_myself.py","r")
def func():
return f
敞天Py
发表于 2023-10-14 10:54:30
1
Caligulasick
发表于 2023-10-16 17:52:09
poi
capf526526
发表于 2023-10-17 14:26:46
see see
zhoutianshu12
发表于 2023-10-17 16:17:33
11
python3366
发表于 2023-10-18 17:38:49
1
afhgfa
发表于 2023-10-18 20:36:44
0. 打开方式是读会报错,写不会
1. 调用flush()
2. 读取3个字节的数据
3. 1行
4. "I love FishC.\n"中有个换行加上print的打印换号,所以看到有一个空白行
5. 需要用'\\'表示一个'\'字符,或者换成原始字符串
6. 文件的内容会全部清除,要确定是不再需要了的
7. 可以
8. 进行操作的文件对象
9. 文件末尾
10.tell()
0.
f = open("FishC.txt", "r")
f.seek(9)
filestr = f.read(6)
f.close()
f1 = open("FishD.txt",'w')
f1.write(filestr)
f1.close()
1.
f = open("FishC.txt", "r")
filestr = f.read(15)
f.close()
f1 = open("FishC.txt",'w')
f1.write(filestr)
f1.close()
2.
f = open("open_myself.py",'r')
filestr = f.read()
print(filestr)
f.close()
3.
f = open("target.zip",'rb')
filestr = f.read()
print(filestr)
f.close()
f1 = open("test.jpg",'ab')
print(f1.tell())
f1.write(filestr)
f1.close()
hxjs_093
发表于 2023-10-19 15:38:19
0:不会,会在文件下直接新建一个文件
1:
meilin1030
发表于 2023-10-19 23:35:44
问答:
0:如果参数不是w就会报错
1:flush()
2:3个字符
3:一行
4:因为print默认会加换行符?
5:文件存在且编码不一致?不是utf-8,不能覆盖?
6:会直接清空内容
7:不行
8:移动到相应位置,进行后续操作
9:文件末尾
10:tell()
动手:
# 第一题
file=open('FishC.txt','r')
file.seek(10)
new = file.read(5)
file.close()
file=open('FishD.txt','w')
file.write(new)
file.close()
# 第二题
file=open('FishC.txt','r+')
file.seek(0)
new = file.read(15)
file=open('FishC.txt','w')
file.write(new)
file.close()
# 第三题
file=open('open_myself.py','r')
x=file.read()
print(x)
# 第四题
file = open('target.zip','rb')
temp = file.read()
file.close()
file = open('test.jpg','ab')
file.write(temp)
file.close()
ln311
发表于 2023-10-23 18:58:04
1
15180162763
发表于 2023-10-25 14:49:44
1
FBI12138
发表于 2023-10-27 10:44:49
0.
不会,会在python文件夹下创造一个文档
1.
f,flush
2.
表示读取size个字符
3.
1行
4.
文本里换行符+已经换行
5.
所以为什么
6.
注意之前不要有重名文本,会覆盖的
7.
可以
8.
指向待读取的字符
9.
文本的末尾字符
10.
seek方法
have a try
0.
f=open('E:\e_Region\download\FishC\FishC.txt','r')
a=f.read(6)
print(a)
FishAF
f1=open('E:\e_Region\download\FishC\FishD.txt','w')
f1.write(a)
6
fi.close()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
fi.close()
NameError: name 'fi' is not defined. Did you mean: 'f'?
f1.close()
1.
f=open('E:\e_Region\download\FishC\FishC.txt','r')
a=f.read(15)
print(a)
FishAFishBFishC
f.close()
f=open('E:\e_Region\download\FishC\FishC.txt','w')
f.write(a)
15
f.close()
2.
不明白
3.
操作不了
gjh121212
发表于 2023-10-28 10:49:31
1
ThePlayer571
发表于 2023-10-28 19:57:45
图一时之快先看答案,你将失去一次锻炼的机会!qyS.P|
y17:s$Of}=?+tg{6Ll;k|#T0@>Cp
请先自己思考和动手,再回复查看参考答案!