python : comma in print as “\t”

You can import the print() function from __future__ and use sep='\t'print() function was introduced in python 3, and it replaced the print statement used in python 2.x:

In [1]: from __future__ import print_function

In [2]: print('a','b',sep='\t')
a   b

help on print():

print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep:  string inserted between values, default a space.
end:  string appended after the last value, default a newline.

Leave a Comment