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.
flush:将缓存里面的内容立即输出到标准输出流(这里是sys.stdout, 也就是默认的显示器),true为立即返回。
若写入文件,flush为false时,f.close()执行前文件无内容,flush为True,则f.close()执行前有内容。
str()和repr()的区别
str():返回用户易读的表达形式
repr():返回解释器易读的表达形式
class str(object)
| str(object=’’) -> str
| str(bytes_or_buffer[, encoding[, errors]]) -> str
repr(obj, /)
Return the canonical string representation of the