Bytes Methods
bytes.expandtabs()
Replace ASCII tab bytes with enough ASCII spaces to reach the next tab stop. Each non-tab byte advances the column by one, except LF and CR reset it to zero. Other control bytes do not reset the column. A nonpositive tab size deletes tabs. Column counting is by bytes, not Unicode display width. Returns bytes.
Formal Syntax & Structure
python syntaxpython
data.expandtabs(tabsize=8)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| tabsize | int | Spacing between tab stops, in byte columns; nonpositive removes tabs. |
Return Value
bytes
bytes with tabs expanded into spaces.
Working Example
Example Snippetpython
print(bytes(b'A\tB').expandtabs(4))print(bytes(b'AB\tC\nX\tY').expandtabs(tabsize=4))print(bytes(b'A\tB').expandtabs(0))