錯(cuò)誤提示:
x = test_images[i].astype('float32').reshape(784.)
TypeError: 'float' object cannot be interpreted as an integer
原因:
- 筆誤今膊,把逗號(hào)",",寫成了小點(diǎn)"."区端,導(dǎo)致Python解釋器認(rèn)為784.是浮點(diǎn)數(shù)。
-
還有容易筆誤的地方:
在Python3使用 '//'就可以達(dá)到原Python2中'/'的效果
Python3中 ‘整數(shù)/整數(shù) = 浮點(diǎn)數(shù)’犬耻, 也就是100 / 2 = 50.0眶蕉;
Python2中 ‘整數(shù)/整數(shù) = 整數(shù)’填帽, 也就是100 / 2 = 50蛛淋;
Python3中的'/'與'//'