Python 大文件操作

old_file_name = input("请输入要复制的文件名(需要后缀)")


f_read = open(old_file_name,"r")


position = old_file_name.rfind(".")
nwe_file_name = old_file_name[0:position]+"[复件]"+old_file_name[position:]
f_write = open (nwe_file_name,"w")


while True:            #定义一个while 循环
content = f_read.read(1024)    
f_write.write(content)
if len(content)==0:
break


f_read.close()
f_write.close()
阅读更多

没有更多推荐了,返回首页