Print full ascii art

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.


print(r"""\

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


                """)

The r allows you to print raw text better especially when there is a lot of inverted commas in the picture that you are trying to print.


I get "...codec can't encode character '\u0ca0' in position..."

If print(giraffe) fails due to an incorrect character encoding then try to set PYTHONIOENCODING environment variable correctly e.g., in bash:

$ PYTHONIOENCODING=utf-8 python3 -c 'from text_art import giraffe as s; print(s)'

Do not use print(giraffe.encode('utf-8')):

  • print() function expects a text, not bytes (unrelated: to print bytes, you could use sys.stdout.buffer.write(some_bytes))
  • how bytes are interpreted as a text is the property of your terminal, you shouldn't hardcode its settings in your code. PYTHONIOENCODING allows you to change the encoding if necessary

print(r"""\

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


            """)
print(r"""\

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


            """)