Search code examples
pythonpython-3.xprintingutf-8ascii

Print full ascii art


I am trying to print ascii art like this:

print(("""\

                                       ._ o o
                                       \_`-)|_
                                    ,""       \ 
                                  ,"  ## |   ಠ ಠ. 
                                ," ##   ,-\__    `.
                              ,"       /     `--._;)
                            ,"     ## /
                          ,"   ##    /


                    """).encode('utf-8'))

And the output does not look right at all.

What is the proper method of printing ascii art?


Solution

  • encode takes a string and encodes it into bytes. That's not what you want here; you want to just print the string directly:

    print("""\
    
                                           ._ o o
                                           \_`-)|_
                                        ,""       \ 
                                      ,"  ## |   ಠ ಠ. 
                                    ," ##   ,-\__    `.
                                  ,"       /     `--._;)
                                ,"     ## /
                              ,"   ##    /
    
    
                        """)
    

    If this doesn't work, your terminal is most likely not configured to display Unicode. Unfortunately, I am not particularly knowledgeable about terminal configuration; Why doesn't my terminal output unicode characters properly? may be relevant, but my ability to help is mostly limited to the Python side of things.