|
发表于 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() |
|