Python print dot art

Hi! So I am trying to print dot art(an image made out of text) in python but it’s printing the code of the characters instead of the actual characters. Why? The file is an rtf. Is that a problem?


it is hard to help you when we do not see your Python code. …and please post it as text, not as an image.

I do not know how is an rtf file related to your Python program. Can you please explain?

well basically it opens the rtf file which contains the dot art, with open() then print( prints out the file but instead of printing the dot art it prints it as this

Rtf aka a Microsoft word document must be processes to generate the text.

What library did you use to process the document?

I don’t like to pick nits, but that is not correct: a RTF (Rich Text Format) file is not synonyms with MS Doc (or Docx, or whatever it is in this day and age; I don’t use it) file.

um I don’t know. I just used the open() thing to open the file,
I did file=open(filename.rtf)
and then print(, I haven’t done anything else. How do I process it what do I need to do?

I have only even seen rtf as a windows format and word can save as that format. Of course doc, docs is not rtf.

Assuming you are on windows you might want to open the file in ms word and try saving as txt. Maybe wordpad might work as well.

RTF (Rich Text Format) is a document format created by Microsoft. Most word processors, including OpenOffice and LibreOffice, are able to read and write .rtf documents.

I don’t know. What do you want it to do?

It isn’t clear to me what you are trying to do. When people talk about “dot-art” (ASCII-art) they usually mean:

  • opening an image file (like a JPEG or GIF)
  • analysing the image
  • and using monospaces ASCII or Unicode text to “draw” the image.

A RTF file is not just a text file, it is a text file filled with formatting codes for all sorts of information, like the size of the page, the paragraph styles, fonts, bold face, italic and more. What are you expecting to do with all those formatting codes?

Well I want to print this in the terminal.

But when I open the file with file=open(‘Galaxy.rtf’) and then do print( it doesn’t work it prints the codes for the characters not the actual characters. I don’t know what to do now. Is there a special way to print this? this is the better screenshot

What program or command did you use to successfully print the Galaxy file in your screenshot? Tell us the steps you used.

What version of Python are you using?

How did you run Python? Again, tell us the steps you used. Are you using an IDE, or running Python from an interactive interpreter, or running a script?

Please copy and paste the code you are using. Not “basically it opens the rtf file which contains the dot art, with open() then print( prints out the file”. We need to see the exact code you are using, not a summary.

Not a screenshot: copy the code, and paste it into your reply as a code block, inside code fences (three backticks):

paste the code here

Note that the backticks need to be on their own lines.

Try running this code, and copying and pasting the output between code fences again:

with open(‘Galaxy.rtf’) as f:
    s =
    print(len(s), repr(s[:20]), repr(s[-20:]))

It looks like you are running a Mac. I don’t know very much about modern Macs, but can you try running these commands from the Terminal app:

file Galaxy.rst
mimetype Galaxy.rst

I’m not sure if that will work, either way copy and paste the output
between code fences again.

I didn’t print the Galaxy file-I copied it form the website where I made it and pasted it into textEdit-this is a text file. I am using Python 3.8.9 and running it with PyCharm.
When I pasted your code this is the output

So now I am pasting my entire code although I am sure most of it is not relevant.

# This is a sample Python script.
import os
import random
import time
import turtle

import art
import keyboard

# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
list=['H','e','l','l','o','!',' ']
list1=['E','n','t','e','r',' ','k','e','y',':']
list2=['D','e','c','r','y','p','t','i','n','g',' ','y','o','u','r',' ','s','e','c','u','r','i','t','y',' ','k','e','y','.','.','.']
list3=['E','n','t','e','r',' ','t','h','e',' ','d','e','c','r','y','p','t','e','d',' ','k','e','y',':']
list4=['H','e','l','l','o','!',' ','W','e','l','c','o','m','e',' ','t','o',' ','t','h','e',' ','G','a','l','a','c','t','i','c',' ','M','a','n','a','g','e','m','e','n','t',' ','S','y','s','t','e','m','!']

#galaxy=open('Galaxy .rtf')
while i<7:


while i<10:

if keyboard.is_pressed('command'):
    print('\033[1;32;49m \n'+bin(r)+"\033[1;0;49m") #0bXXX
    while i<31:


    while i<24:

else: os.system('clear'); print("\033[1;31;49mError! Access Denied!"); quit()

print('\033[0;32;49m', end='')

if input()==key:
    print("\033[1;0;49m", end='')

    while i<49:

    with open('Galaxy .rtf') as f:
        s =
        print(len(s), repr(s[:20]), repr(s[-20:]))


else:os.system('clear'); print("\033[1;31;49mError! Access Denied!"); quit()

On that web site can you save as text and not as rtf?

No you can only copy and paste you can’t download it or I can’t seem to find a way.