This article mainly introduces the method of implementing python print separated by commas or spaces. It has certain reference value. Now I will share it with you if you need it. Friends can refer to
1) Press to separate
a, b = 0, 1 while b < 1000: print(b, end=',') a, b = b, a+b 1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
2 ) Separated by spaces
a, b = 0, 1 while b < 1000: print(b, end=' ') a, b = b, a+b 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
3) How to use print
print(...) print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) 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. flush: whether to forcibly flush the stream.
Related recommendations: "Python Tutorial 》
The above is the detailed content of python print method separated by comma or space. For more information, please follow other related articles on the PHP Chinese website!