writer

FileInputStream vs FileReader

 ̄綄美尐妖づ 提交于 2019-11-26 09:19:55
问题 FileReader rd=new FileReader(\"new.mp4\"); FileWriter wr=new FileWriter(\"output.mp4\"); int ch; while((ch=rd.read())!=-1) wr.write(ch); wr.flush(); wr.close(); When I use the FileReader and FileWriter to read and write an mp4 file, the output.mp4 file can\'t be rendered well. But when I use FileInputStream and FileOutputStream instead it worked well. So can I conclude FileReader and FileWriter are only for reading and writing text? 回答1: Yes, your conclusion is correct subclasses of Reader

append new row to old csv file python

不羁岁月 提交于 2019-11-26 03:27:31
问题 I am trying to add a new row to my old csv file. Basically, it gets updated each time I run the Python script. Right now I am storing the old csv rows values in a list and then deleting the csv file and creating it again with the new list value. Wanted to know are there any better ways of doing this. 回答1: with open('document.csv','a') as fd: fd.write(myCsvRow) Opening a file with the 'a' parameter allows you to append to the end of the file instead of simply overwriting the existing content.