Brian D
Brian D

Reputation: 10153

Modify the width of a tab in a format string

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

Upvotes: 15

Views: 20238

Answers (2)

jlp
jlp

Reputation: 879

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

Upvotes: 23

Mark Byers
Mark Byers

Reputation: 838806

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.

Upvotes: 10

Related Questions