osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


print(repr(message))  out :

*does not exist\r\n\tat com.*


for ch in message:
  printf("%d %c",ch, chr(ch))


%d %c 110 n
%d %c 111 o
%d %c 116 t
%d %c 32
%d %c 101 e
%d %c 120 x
%d %c 105 i
%d %c 115 s
%d %c 116 t

*%d %c 13%d %c 10*
*%d %c 9*
%d %c 97 a
%d %c 116 t
%d %c 32
%d %c 99 c
%d %c 111 o
%d %c 109 m





On Sun, Jan 28, 2018 at 9:50 AM, Steven D'Aprano <
steve+comp.lang.python at pearwood.info> wrote:

> On Sat, 27 Jan 2018 21:23:02 -0500, Jason Qian via Python-list wrote:
>
> > there are 0D 0A 09
>
> If your string actually contains CARRIAGE RETURN (OD) NEWLINE (OA), and
> TAB (09) characters, then you don't need to do anything. Just call print,
> and they will be printed correctly.
>
> If that doesn't work, then your input string doesn't contain what you
> think it contains. Please call this:
>
>     print(repr(the_string))
>
> and COPY AND PASTE the output here so we can see it.
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>