+ 1

ASCII animation with python

I'm trying to do a multi-line ascii animation in Python 3. As I understand it, sys.stdout.write("\r"*(some_number)) will at most take me to the beginning of the current line. Can I also go back multiple lines? Example: I want a flashing x-o pattern (alternating) so I need to go back 5 lines: xx xx xx xx xx xx xx xx xx ooo oo oo oo oo oo oo ooo

21st Jul 2018, 1:31 PM
Najum
Najum - avatar
4 Answers
+ 5
import os os.system('clear') #Linux os.system('CLS') #Windows
21st Jul 2018, 8:09 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 4
And you can use asciimatics https://pypi.org/project/asciimatics/
21st Jul 2018, 8:11 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 1
Which package is "clear" in?
21st Jul 2018, 4:04 PM
Najum
Najum - avatar
0
why not store that data in a multiline string? X = """XX XX XX XX XX XX XX XX XX""" O = """ ooo o o o o ooo""" then use a combination of delay and the "clear" command to change between X and O
21st Jul 2018, 3:09 PM
Bebida Roja
Bebida Roja - avatar