Please help on print string that contains 'tab' and 'newline'

Terry Reedy tjreedy at udel.edu
Sat Jan 27 17:39:06 EST 2018


On 1/27/2018 3:15 PM, Jason Qian via Python-list wrote:
> HI
> 
>     I am a string that contains \r\n\t
> 
>     [Ljava.lang.Object; does not exist*\r\n\t*at com.livecluster.core.tasklet
> 
> 
>     I would like it print as :
> 
> [Ljava.lang.Object; does not exist
>    tat com.livecluster.core.tasklet

Your output does not match the input.  Don't add, or else remove, the *s 
if you don't want to see them.  Having '\t' print as '  t' makes no sense.

In IDLE

 >>> print('[Ljava.lang.Object; does not exist*\r\n\t*at 
com.livecluster.core.tasklet')
[Ljava.lang.Object; does not exist*
	*at com.livecluster.core.tasklet

IDLE ignores \r, other display mechanisms may not.  You generally should 
not use it.

Pasting the text, with the literal newline embedded, does not work in 
Windows interactive interpreter, so not testing this there.


-- 
Terry Jan Reedy




More information about the Python-list mailing list