Santhej Kallada
Santhej Kallada

Reputation: 45

How can I make the following text appear in my python program?

I want to display the following text in my program.When ever I paste the following text in python it interprets backslash as escape sequence and mess ups my ascii art..any idea to get this solved geeks.Here is the text I want to appear in my program

  _  __     _ _           _         ____            _               _                 
 | |/ /__ _| | | __ _  __| | __ _  |  _ \ __ _  ___| | ____ _  __ _(_)_ __   __ _ ___ 
 | ' // _` | | |/ _` |/ _` |/ _` | | |_) / _` |/ __| |/ / _` |/ _` | | '_ \ / _` / __|
 | . \ (_| | | | (_| | (_| | (_| | |  __/ (_| | (__|   < (_| | (_| | | | | | (_| \__ \
 |_|\_\__,_|_|_|\__,_|\__,_|\__,_| |_|   \__,_|\___|_|\_\__,_|\__, |_|_| |_|\__, |___/
                                                              |___/         |___/     

Upvotes: 1

Views: 247

Answers (3)

unddoch
unddoch

Reputation: 6014

ascii_art = r"""_  __     _ _           _         ____            _               _                 
 | |/ /__ _| | | __ _  __| | __ _  |  _ \ __ _  ___| | ____ _  __ _(_)_ __   __ _ ___ 
 | ' // _` | | |/ _` |/ _` |/ _` | | |_) / _` |/ __| |/ / _` |/ _` | | '_ \ / _` / __|
 | . \ (_| | | | (_| | (_| | (_| | |  __/ (_| | (__|   < (_| | (_| | | | | | (_| \__ \
 |_|\_\__,_|_|_|\__,_|\__,_|\__,_| |_|   \__,_|\___|_|\_\__,_|\__, |_|_| |_|\__, |___/
                                                              |___/         |___/     """
print ascii_art

Use r"""text""" to avoid backslashes escaping EOL's.

Upvotes: 1

DanielB
DanielB

Reputation: 2958

You can use raw strings:

myString = r'''_  __     _ _           _         ____            _               _                 
 | |/ /__ _| | | __ _  __| | __ _  |  _ \ __ _  ___| | ____ _  __ _(_)_ __   __ _ ___ 
 | ' // _` | | |/ _` |/ _` |/ _` | | |_) / _` |/ __| |/ / _` |/ _` | | '_ \ / _` / __|
 | . \ (_| | | | (_| | (_| | (_| | |  __/ (_| | (__|   < (_| | (_| | | | | | (_| \__ \
 |_|\_\__,_|_|_|\__,_|\__,_|\__,_| |_|   \__,_|\___|_|\_\__,_|\__, |_|_| |_|\__, |___/
                                                          |___/         |___/'''
# note the r before the string starts

More Info

Try testing the difference between print '\tHello, world!' and print r'\tHello, World!'

Upvotes: 8

Ashwini Chaudhary
Ashwini Chaudhary

Reputation: 251196

use triple quotes, place this text between """ """

>>> strs="""_  __     _ _           _         ____            _               _                 
 | |/ /__ _| | | __ _  __| | __ _  |  _ \ __ _  ___| | ____ _  __ _(_)_ __   __ _ ___ 
 | ' // _` | | |/ _` |/ _` |/ _` | | |_) / _` |/ __| |/ / _` |/ _` | | '_ \ / _` / __|
 | . \ (_| | | | (_| | (_| | (_| | |  __/ (_| | (__|   < (_| | (_| | | | | | (_| \__ \
 |_|\_\__,_|_|_|\__,_|\__,_|\__,_| |_|   \__,_|\___|_|\_\__,_|\__, |_|_| |_|\__, |___/
                                                              |___/         |___/     """
>>> print(strs)
_  __     _ _           _         ____            _               _                 
 | |/ /__ _| | | __ _  __| | __ _  |  _ \ __ _  ___| | ____ _  __ _(_)_ __   __ _ ___ 
 | ' // _` | | |/ _` |/ _` |/ _` | | |_) / _` |/ __| |/ / _` |/ _` | | '_ \ / _` / __|
 | . \ (_| | | | (_| | (_| | (_| | |  __/ (_| | (__|   < (_| | (_| | | | | | (_| \__  |_|\_\__,_|_|_|\__,_|\__,_|\__,_| |_|   \__,_|\___|_|\_\__,_|\__, |_|_| |_|\__, |___/
                                                              |___/         |___/   

Upvotes: 3

Related Questions