Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does printing a tabulator not always print a tabulator but a space?

this might be a simple question but I haven’t found a solution or a similar question yet.
When printing

print(str(n) + "\t" + str(abs(moved_nm.value)) + "\t" + str(truncate(diff_2, 2)) + "\t" + str(truncate(diff_abs, 2)))

It prints

3   9999375 9935347.98  64027.01

Why does the first \t print a tabulator while the rest don’t?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It actually does print tabulators. The ASCII code of your string is:

51 9 57 57 57 57 51 55 53 9 57 57 51 53 51 52 55 46 57 56 9 54 52 48 50 55 46 48 49 

(you can check here)

The code for tabulator is 9 and your string contains 3 of them, 1 between each word.

Note that a tabulator does not always appear to have the same length, it adjusts the length to get to the beginning of the next column. It is useful in case you want a column that starts at the same position at each line, but be careful to not allow to long words or it will expand until the next column beginning.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading