Python print函數使用

 


 本文連接:http://www.javashuo.com/article/p-yjuqvapz-p.html


 函數定義

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 便可,這樣能夠得到較好的性能。html

相關文章
相關標籤/搜索