Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print multiple line string in Jupyter notebook

I'm trying to print a multiple line string to a Jupyter notebook. The problem is that \r and \n are printed literally and not interpreted as newlines.

Example:

import os
os.linesep.join(['first line', 'second line'])

I would expect this to print:

first line
second line

But it prints:

first line\r\nsecond line
like image 546
blokeley Avatar asked May 07 '17 18:05

blokeley


1 Answers

You need to actually print it.

import os
print(os.linesep.join(['first line', 'second line']))
like image 125
vishes_shell Avatar answered Oct 08 '22 16:10

vishes_shell