Y.Du
Y.Du

Reputation: 427

how to print whitespaces like newline character '\n' to the screen in Python?

I use Mac and python2, and I want to check which characters are considered as whitespaces by my operation system.

In IDLE, it returns '\t\n\x0b\x0c\r ', which is good.

But I use pycharm editor and when I use the following code:

import string
print string.whitespace

Then instead of getting the whitespace characters '\t\n\x0b\x0c\r ', I actually get a tab, a newline ect. characters printed.

How could I get my result in a form of string instead of the actual actions of these whitespaces?

Upvotes: 0

Views: 645

Answers (1)

jayme
jayme

Reputation: 1316

Not sure if I got you right. Do you want to see the representation like:

import string
print repr(string.whitespace)

Upvotes: 1

Related Questions