fob = open("LISA designshpe.txt", "r+")
foc = open ("n.txt","w+")
s = fob.readlines()
fob.close()
for a in s :
line =foc.write( a )
foc.close()
答案 0 :(得分:1)
应该适用于Python 2.7及更高版本:
with open("infilename") as infile, open("outfilename", 'w') as outfile:
# outfile.write(infile.read()) # read entire file at once
outfile.writelines(line for line in infile) # read file line by line
或只是复制文件:
import shutil
shutil.copy("infilename", "outfilename")
参考文献:
答案 1 :(得分:0)
只需使用writelines()
:
foc.writelines(s)