只需键入 print 只会在 python 中提供换行符。在 3.x 中键入不带括号的 print 也会产生换行符。为什么?
请您参考如下方法:
因为 the documentation这么说
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)Print objects to the text stream file, separated by sep and followed by end. sep, end and file, if present, must be given as keyword arguments.
All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no objects are given,
print()will just writeend.The file argument must be an object with a write(string) method; if it is not present or None, sys.stdout will be used. Since printed arguments are converted to text strings, print() cannot be used with binary mode file objects. For these, use file.write(...) instead.
Whether output is buffered is usually determined by file, but if the flush keyword argument is true, the stream is forcibly flushed.
Changed in version 3.3: Added the flush keyword argument.
请注意,end 默认为 '\n',这是一个新行。
