Whenever I try to print out the ascii values of for example DEC 127( : DEL) I get a box with a diagonal line means it doesn't get recognized but as soon as I copy these boxes and paste them into PyCharm(2021.2.3) I get the letters "DEL". Another example is, if I print out DEC 10( : LF) what is equal to "\n" it just prints out the new line. So my Question:
Is there any way I can print "DEL" and "LF" instead of the boxes?
Here is the code I use:
for i in range(128)
ascii_table[str(i)] = chr(i)
And then I display it with:
ascii_table_width = 10
for key, item in ascii_table.items():
print(f"{key} : {item}", end=" | ")
if int(key) % ascii_table_width == 0:
print("\n")
And even weirder is, if I display it with:
print(ascii_table)
I get as the value of the key "127" a string with the escape character(\) and after that the corresponding value of DEL: '\x7f'. For 10 it is '\n'. This better than the box but still not what I want. I want to have DEL and LF to show up.
The thing is, that when I do this:
print(ascii_table["127"])
it definitely should print out '\x7f' like before but no, it prints out the box again.
And if I run
>>>print(chr(1))
in python inside the Command Prompt I even get a smiley instead of the box and for 127 it is a symbol that looks like a house. For 10 it is just a new line.
I just find it really interesting. Does anyone has an explanation for this phenomenon?