2024-09-27 23:16:15 发布
网友
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()
只需使用writelines():
writelines()
foc.writelines(s)
应与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
或者只是复制文件:
参考文献:
只需使用
writelines()
:foc.writelines(s)
应与Python 2.7及更高版本配合使用:
或者只是复制文件:
^{pr2}$参考文献:
相关问题 更多 >
编程相关推荐