Reputation: 876
I use Python in Jupyternotebook. I mainly work with hdf5
or netcdf4
data, so there are always descriptions along with the data. When I want to read and view multiple data at the same time, I would use
print(A)
print(B)
print(C)
...
Then the problem is that when the descriptions are really long, it is hard to distinguish which paragraphs are for which data. I tried this to help me separate them.
print(A)
print('-------------------------------')
print(B)
But this may introduce too many additional lines. Is there any smarter way to solve this? Thanks.
Upvotes: 2
Views: 634
Reputation: 876
Thanks to the inspiration from @Vicrobot
and @DuDoff
, I may use this:
print(A,B,C,D,E,sep = '\n##########################\n')
Upvotes: 0
Reputation: 3988
You can use sep
argument, and can use *
to produce pattern string:
print(A, '-'*20, B, sep = '\n')
Upvotes: 2
Reputation: 3000
What about using f-strings
like:
>>> A = "My A"
>>> print(f'This is A: \n{A}')
This is A:
My A
OR
>>> print(f'### A ###\n{A}')
### A ###
My A
Upvotes: 1