初學者需要分清這兩個概念
>>> type(print)
<class 'builtin_function_or_method'>
print 不加括號,屬於內置的函數或方法
>>> type(print())
<class 'NoneType'>
print加括號,相當於執行print函數,函數執行完畢後都會有返回值,如果沒有手動指定返回值,那麼一般會默認返回None,可見print函數執行完畢後返回的就是None。
初學者需要分清這兩個概念
>>> type(print)
<class 'builtin_function_or_method'>
print 不加括號,屬於內置的函數或方法
>>> type(print())
<class 'NoneType'>
print加括號,相當於執行print函數,函數執行完畢後都會有返回值,如果沒有手動指定返回值,那麼一般會默認返回None,可見print函數執行完畢後返回的就是None。