鍍金池/ 問答/Python/ Python3:為什么 print() 括號里什么都沒有,也能打印輸出?

Python3:為什么 print() 括號里什么都沒有,也能打印輸出?

為什么 print() 括號里什么都沒有,也能打印輸出?print()在函數(shù)的末尾。

以下為代碼:

def fib(n):    # write Fibonacci series up to n
    """Print a Fibonacci series up to n."""
    a, b = 0, 1
    while a < n:
        print(a, end=' ')
        a, b = b, a+b
    print()

# Now call the function we just defined:
fib(2000)

謝謝。

回答
編輯回答
終相守

輸出的內(nèi)容都是在print(a,end=' ') 內(nèi)的,print() 這是用來換行的

2017年12月18日 21:39