python - 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:
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.
解决方案
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}")
推荐阅读
- microcontroller - 当我写入内存映射寄存器时会发生什么?
- r - 根据条件删除多个列
- javascript - 如何将数据从 nodejs 发送到 js?
- html - 尝试使用 AngularJS 创建重复的水平 div 滚动
- text - 如何在 Vscode 中调整非文本编辑器字体大小
- python - 熊猫:Groupby 外部触发器(时间序列)
- javascript - 将 Django 变量发送到 javascript
- ruby-on-rails - 长时间空闲后,Rails 无法验证 CSRF 令牌的真实性
- c++ - 导入什么 DLL 以手动使用 C++ cout?
- python-3.x - 多个相同进程的 Gunicorn 高内存使用率?