Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify the width of a tab in a format string

Tags:

python

Is it possible to redefine the space width of a tab when printing a \t character in python?

like image 802
Brian D Avatar asked Oct 04 '11 05:10

Brian D


2 Answers

Python's print feature does not convert tabs to spaces - it outputs a literal tab. The way it appears depends on what program you use to view it.

like image 103
Mark Byers Avatar answered Nov 18 '22 09:11

Mark Byers


Try pydoc string.expandtabs, I think it will do what you want.

like image 20
jlp Avatar answered Nov 18 '22 09:11

jlp