#1木西、通用文件copy工具實現(xiàn)
"""
src_file =input("源文件路徑:")
dst_file =input("源文件路徑:")
with open(r"35.jpg","rb")as f1,\
open(r"35.jpg","wb")as f2:
for linein f1:
f2.write(line)
"""
#2金赦、基于seek控制指針移動屹培,測試r+、w+胳挎、a+模式下的讀寫內(nèi)容
"""
with open("a.txt","rb+") as f:
f.seek(3,0)
f.seek(2,0)
# print(f.tell())
f.seek(4,0)
res = f.read()
print(res.decode("utf-8"))
"""
"""
with open("a.txt","wb+") as f:
f.seek(5,1)
f.seek(3,1)
? ? f.write("hello python\n".encode("utf-8"))
? ? f.write("您好世界\n".encode("utf-8"))
"""
"""
with open("a.txt","ab+") as f:
f.seek(-2,2)
f.seek(-5,2)
print(f.tell())
? ? f.write("hello world\n".encode("utf-8"))
? ? f.write("perseverance prevails\n".encode('utf-8'))
"""