Problem with viewing string output in Google Colab

enter image description here

I was supposed to obtain an output like this when i run the command 'print(abide.description)' But the output I am obtaining is something like this. The entire string is shown in a single line which is making it quite difficult to read and interpret. How can I obtain the output as the picture above?

My code snippet:

print(abide.description)

The output: enter image description here

Upvotes: 0

Views: 1394

Answers (1)

jakevdp
jakevdp

Reputation: 86310

The issue is that abide.description is returning bytes rather than a string. If you want it to print as a normal string, you can use the bytes.decode() method to convert the bytes to a unicode string.

For example:

content_bytes = b'this is a byte string\nand it will not be wrapped\nunless it is first decoded'

print(content_bytes)
# b'this is a byte string\nand it will not be wrapped\nunless it is first decoded'

print(content_bytes.decode())
# this is a byte string
# and it will not be wrapped
# unless it is first decoded

Upvotes: 0

Related Questions