文件复制 # 要求:将一个文件,复制到另外一个副本中 # # 步骤分析:1.以只读的方式打开a文件。以追加模式打开b文件 # source = open ( "af.txt" , "r" , encoding = "utf-8" ) fuben = open ( "bf.txt" , "
文件复制
source = open("af.txt", "r", encoding="utf-8")
fuben = open("bf.txt", "a", encoding="utf-8")
while True:
content = source.read(1024) #每次读取1024
if len(content) == 0:
break
fuben.write(content) #每次写入1024
source.close()
fuben.close()