How to write output file in CSV format in python?

前端 未结 4 1891
忘了有多久
忘了有多久 2021-01-07 04:11

I tried to write output file as a CSV file but getting either an error or not the expected result. I am using Python 3.5.2 and 2.7 also.

Getting error in Python 3.5:

4条回答
  •  旧时难觅i
    2021-01-07 04:24

    You are opening the input file in normal read mode but the output file is opened in binary mode, correct way

    resultFile = open("out.csv", "w")
    

    As shown above if you replace "wb" with "w" it will work.

提交回复
热议问题