TypeError: int() argument must be a string or a number, not 'NoneType' 常常在做操作或有一個問題就是把string轉成int做比較, 可是卻因為某個沒有值的None type讓程式出錯了, 為了避免這個問題, 使用了這一個小技巧。 int(value or 0) 這樣就可以把其他值轉成0 減少程式發生錯誤了。 python how to convert Nonetype to int or string - Stack Overflow http://stackoverflow.com/questions/3930188/python-how-to-convert-nonetype-to-int-or-string
創作者介紹
創作者 FLASHC 的頭像
peicheng

FLASHC

peicheng 發表在 痞客邦 留言(0) 人氣( 1037 )