|  | 
 
 发表于 2023-11-29 22:06:49
|
显示全部楼层 
| 不会 flush()
 读取3个字符
 1行
 for语句会自动添加一个换行符
 没有使用原始字符串
 文件内容是否需要
 可以
 end of file
 tell()
 old_f=open(r"D:\learn\Download\FishC.txt","r")
 new_f=open(r"D:\learn\Download\FishD.txt","w")
 new_f.close()
 new_f=open(r"D:\learn\Download\FishD.txt","r+")
 old_f.seek(10,0)
 s=old_f.read(5)
 new_f.write(s)
 new_f.close()
 old_f.close()
 、
 f=open(r"D:\learn\Download\FishC.txt","r")
 s=f.read(15)
 f=open(r"D:\learn\Download\FishC.txt","w")
 f.write(s)
 、
 f=open(r"open_myself.py","r")
 print(f.read())
 、
 import os
 print(os.getcwd())
 target=open(r"Download\hw\target.zip","rb")
 test=open(r"Download\hw\test.jpg","ab")
 test.write(target.read())
 target.close()
 test.close()
 | 
 |