Python3: writing csv files

后端 未结 6 2002
盖世英雄少女心
盖世英雄少女心 2020-12-01 07:26

I\'m trying to use Python 3.2 on a Windows computer to write a simple CSV file, however I\'m having no luck. From the csv module documentation for Python 3.2:



        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 08:12

    [For Python 2.x] This implementation of spamWriter is working for me...

    with open('assignmentresults.csv', 'wb') as csvfile:
      spamwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
      spamwriter.writerow(["Hullo", "World"])
    

提交回复
热议问题