Print full ascii art

I am trying to print the art of ascii as follows:

print(("""\

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


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

And the result does not look right.

What is the correct way to print ascii art?

+5
source share
6 answers

encodetakes a string and encodes it into bytes. This is not what you want here; you want to just print the line directly:

print("""\

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


                    """)

If this does not work, your terminal is most likely not configured to display Unicode. Unfortunately, I am not very good at terminal configuration; Why is my terminal not displaying unicode characters correctly? may be appropriate, but my ability to help is mostly limited on the Python side.

+9
print(r"""\

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


                """)

r , , , .

+7

"... " \u0ca0 " ..."

print(giraffe) - , PYTHONIOENCODING, , bash:

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

print(giraffe.encode('utf-8')):

  • print() , (: , sys.stdout.buffer.write(some_bytes))
  • , , . PYTHONIOENCODING
+2

''.encode('utf-8')

ASCCII, Python 3.6.7 Ubuntu
__header__ = '''Content-Type: application/xml

\033[92m        .---------------------------------.
\033[92m        |  .---------------------------.  |
\033[92m        |[]|\033[94m         __   __   *       \033[92m|[]|
\033[92m        |  |\033[94m        /  | /  | /        \033[92m|  |
\033[92m        |  |\033[94m       (___|(___|(         \033[92m|  |
\033[92m        |  |\033[94m       |   )|    |         \033[92m|  |
\033[92m        |  |\033[94m       |  / |    |         \033[92m|  |
\033[92m        |  |\033[94m /              |         |\033[92m|  |
\033[92m        |  |\033[94m(  ___  ___  ___| ___  ___|\033[92m|  |
\033[92m        |  |\033[94m| |   )|   )|   )|___)|   )\033[92m|  |
\033[92m        |  |\033[94m| |__/ |__/||__/ |__  |__/ \033[92m|  |
..And more

print(__header__)

Ubuntu-Python3-print (ASCII)

0
print(r"""\

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


            """)
print(r"""\

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


            """)
0
source
           _.' :  '._               
            .-.''.  ;   .''.-.           
   __      / : ___\ ;  /___ ; \      __  
 ,'_ ""--.:__;".-.";: :".-.":__;.--"" _',
 :' '.t""--.. '<@.';_  ',@>' ..--""j.' ';
      ':-.._J '-.-'L__ '-- ' L_..-;'     
        "-.__ ;  .-"  "-.  : __.-"       
            L ' /.------.\ ' J           
             "-.   "--"   .-"            
            __.l"-:_JL_;-";.__           
         .-j/'.;  ;""""  / .'\"-.        
       .' /:'. "-.:     .-" .';  '.      
    .-"  / ;  "-. "-..-" .-"  :    "-.   
 .+"-.  : :      "-.__.-"      ;-._   \  
 ; \  '.; ;                    : : "+. ; 
 :  ;   ; ;                    : ;  : \: 
 ;  :   ; :                    ;:   ;  : 
: \  ;  :  ;                  : ;  /  :: 
;  ; :   ; :                  ;   :   ;: 
:  :  ;  :  ;                : :  ;  : ; 
;\    :   ; :                ; ;     ; ; 
: '."-;   :  ;              :  ;    /  ; 
 ;    -:   ; :              ;  : .-"   : 
 :\     \  :  ;            : \.-"      : 
  ;'.    \  ; :            ;.'_..--  / ; 
  :  "-.  "-:  ;          :/."      .'  :
   \         \ :          ;/  __        :
    \       .-'.\        /t-""  ":-+.   :
     '.  .-"    'l    __/ /'. :  ; ; \  ;
       \   .-" .-"-.-"  .' .'j \  /   ;/ 
        \ / .-"   /.     .'.' ;_:'    ;  
         :-""-.'./-.'     /    '.___.'   
               \ 't  ._  /  bug you have         
                "-.t-._:'    
-3
source

Source: https://habr.com/ru/post/1540321/


All Articles