|
发表于 2020-10-15 09:14:46
|
显示全部楼层
>>> help(print)
Help on built-in function print in module builtins:
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.
==============================
注意看帮助文档。print()函数默认的end是等于一个换行符。
也就是说例如print("hellow world"),实际等于print("hellow world",end="\n")。
也就是是打印"hellow world"+换行符。
你print("hellow world",end=''),就是把end参数定义为空,就不会换行了 |
|