リストのリストをcsvファイルに保存しようとしましたが、私はcsvモジュールを使用しました。Pythonでcsvファイルを書く:関数の書き出しでエラーが発生する
import csv
a = [[1.2,'abc',3],[1.2,'werew',4],[1.4,'qew',2]]
with open("output.csv", "wb") as f:
writer = csv.writer(f)
writer.writerows(a)
私はこのスクリプトを実行すると、エラーメッセージが表示されます:
Traceback (most recent call last):
File "csv-ex.py", line 5, in <module>
writer.writerows(a)
TypeError: a bytes-like object is required, not 'str'
誰もが欠落していることを知っているここに私のスクリプトはありますか?