為什麼會多了None這個顯示?

70 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

Dincht Wu

غير مقروءة،
08‏/06‏/2018، 9:22:50 ص8‏/6‏/2018
إلى python.tw
if __name__ == '__main__':
   
print(mlt.model)
   
print(mlt.showModInf())

顯示結果如下:
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)
Model Information: LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)
None

"mlt" 為自訂類別, ".model" 是類別引用的模組,以下顯示 ".showModInf()" 的程式碼。
class ML_tools:
 
from sklearn.linear_model import LinearRegression
 model
= LinearRegression()
...
 
def showModInf(self): print('Model Information:', self.model)
...

其實showModInf()的方法就等同於屬性model的顯示,但不懂的是,為什麼調用showModInf()會多一行None?
在此請教個位前輩們。

Sonic Yang

غير مقروءة،
09‏/06‏/2018، 11:59:14 ص9‏/6‏/2018
إلى pyth...@googlegroups.com
我猜是因為print() 會回none

alingo
--
這是 Google 網上論壇針對「python.tw」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 pythontw+unsubscribe@googlegroups.com
如要在這個群組張貼留言,請傳送電子郵件到 pyth...@googlegroups.com
請前往以下網址造訪這個群組:https://groups.google.com/group/pythontw
如需更多選項,請前往:https://groups.google.com/d/optout
الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة