LoginSignup
0
0

More than 3 years have passed since last update.

入門Python3 正誤表P288 改行が余計に追加される

Posted at

[入門Python3 BillLubanovic著」を、読んでうまく動かなかったところのメモです。

 不具合

P.288
with open('villains', 'rt') as fout:
csvout = csv.writer(fout)
csvout.writerows(villains)

を実行した際に、各行に改行が余計に追加されてしまう問題がある。

 対策

open関数に newline引数を指定したら正しく(参考書通りに)動作しました。

with open('villains', 'rt', newline='') as fout:

https://docs.python.org/ja/3/library/csv.html#examples
このページの一番下に書かれてました。

Skype理工学勉強会では、同書の読書写経会をしています。
Skype上の無料オンライン会です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0