Python print函数使用
程序员文章站
2022-06-20 09:00:44
本文链接:https://www.cnblogs.com/zyuanlbj/p/11905405.html 函数定义 def print(self, *args, sep=' ', end='\n', file=None): # known special case of print """ pri ......
本文链接:
函数定义
def print(self, *args, sep=' ', end='\n', file=none): # known special case of 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.
"""
函数用法
# 1.用法 print('hello world!') name = '小白' print(name) #2.用法:print(name,age,gender) age =18 gender ='boy' print(name,age,gender) # sep默认的分割是空格 # 3.用法: print(value1,value2,value3,...,sep=' ',end='\n') print(name,age,gender,sep='-') # sep=‘*’ sep='$' sep='-'
print() 函数的 flush 参数用于控制输出缓存,该参数一般保持为 false 即可,这样可以获得较好的性能。