首页 > 解决方案 > Draw dots based on (x,y) locations

问题描述

So I got .txt file with around 200 lines, each contains a (x,y) location ranging from 0 to 255. I want to draw dot, or "," at each location.. so (0,5) will draw 5 spaces in first line and then the ",".

Using python, is there a way to print it to the terminal that way? if not, is there a way to create .txt file with the "image" or any other way to view the resulting "image" (its just bunch of ","'s) thanks.

EDIT:

The .txt file is something I extracted from challenge. The challenege was to decode the output of given binary file. This is the original file: https://elbitcareer.hunterhrms.com/wp-content/uploads/elbitsystems.elbit

This is the .txt coords I managed to extract from the file: https://easyupload.io/imtbdn

And this is what it looks like when I print it to the terminal: enter image description here

It looks like the right direction (SYSCO..?) but something is off.. Any ideas on what is the problem?

EDIT2: So my .txt file was missing some points and my terminal window needed some resizing.. now it kinda workds! thanks all.

标签: pythonimagecoordinatespixel

解决方案


Here is a little function using ANSI escape codes to do that.

def print_at(x, y, txt):
    """
    Print txt on a specific coordinate of the terminal screen.
    """
    print(f"\033[{y};{x}H{txt}")

推荐阅读