代码如下:
#encoding:utf-8 #本程序实现文件复制功能 source_file=open("d.txt","r",encoding="utf-8") dst_file=open("e_bat.txt","a",encoding="utf-8")#a表示追加,如果没有该文件则新建它 while True: content=source_file.read(1024)#每次读1024个字节 if len(content)==0:#如果读完了,就跳出循环 break dst_file.write(content)#将读取到的内容写入目标文件 source_file.close() dst_file.close()