I would like to be able to colour a character cell in python where the character cell to be coloured is determined by two variables (one for the line one for the column).
I've tried string parsing and string concatenation but I can't work out why they don't work.
sys.std(u"\u033[%d;%dH\u001b[47m\033[0m" % (y, x))
code = 47
sys.stdout.write(u"\u001b[81;23f\u001b[" + str(code) + "m " + RESET )
sys.stdout.write(u"\u001b[" + str(x) + ";23f\u001b[" + str(code) + "m " )
The first one says: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-4: truncated \uXXXX escape
The second line works, it colours the character cell at line 81 column 23 grey. But the third line prints "\u001b[47m" at line 81 column 23 instead of outputting a coloured pixel.
I don't really understand why the string concatenation works for the second one and not the third. Ideally, I'd like to be able to change the values 81 and 23 using variables i.e x and y.
I've been pondering this for quite a few hours now and would appreciate some insight.