1

I want to print this text 'aÀXysc \n§Ä tIÄ¡p¶ntÃ'

like this

'aÀXysc \n§Ä tIÄ¡p¶ntÃ'

but when I tried to do that its printing like this '

aÀXysc 
§Ä tIÄ¡p¶ntÃ

how can I ignore\n

5 Answers5

2

You can use r to make \n lose its special meaning.

print(r'aÀXysc \n§Ä tIÄ¡p¶ntÃ')
# aÀXysc \n§Ä tIÄ¡p¶ntÃ
pppig
  • 1,215
  • 1
  • 6
  • 12
1

You can simply scape \ by using \\

>> print('aÀXysc \\n§Ä tIÄ¡p¶ntÃ')
aÀXysc \n§Ä tIÄ¡p¶ntÃ

or you can use a raw string by prepending an r to the string

>> print(r'aÀXysc \n§Ä tIÄ¡p¶ntÃ')
aÀXysc \n§Ä tIÄ¡p¶ntÃ
lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228
1

You can use the repr function to get the string representation of the value:

>>> print(repr('aÀXysc \n§Ä tIÄ¡p¶ntÃ'))
'aÀXysc \n§Ä tIÄ¡p¶ntÃ'
blhsing
  • 91,368
  • 6
  • 71
  • 106
1

You can print it as a raw string by prefixing it with r.

>>> print(r'aÀXysc \n§Ä tIÄ¡p¶ntÃ')
aÀXysc \n§Ä tIÄ¡p¶ntÃ
Devansh Soni
  • 771
  • 5
  • 16
0

Two ways:

First Method: You can try use the repr function like so:

my_string = 'aÀXysc \n§Ä tIÄ¡p¶ntÃ'
print(repr(my_string))

Second Method: Use the double \ back lash, like so:

my_string = 'aÀXysc \\n§Ä tIÄ¡p¶ntÃ'
print(my_string)

Output:

aÀXysc \n§Ä tIÄ¡p¶ntÃ
Its Fragilis
  • 210
  • 2
  • 9