LoginSignup
1
1

More than 5 years have passed since last update.

IPython Notebook上で文字列の表示

Last updated at Posted at 2015-09-01

IPython Notebook上で以下のコードを実行すると,文字列がそのまま表示され,改行されません.

msg = 'test\ntest\ntest\n'
msg
>>> 'test\ntest\ntest\n'

解決策

以下の様にprint()すると改行して表示されます.

msg = 'test\ntest\ntest\n'
print(msg)
>>> test
>>> test
>>> test

ちなみに,自分はsklearnのclassification_report()関数を使って分類の結果を表示しようとしているときに,この問題?に陥りました.

こういう基本的なことはチュートリアルなどに載っていないし,なんて検索したら出てくるのかも分からず,15分ほど時間を無駄にしました...

1
1
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
1
1