from array import array
scores = array('d')
scores.append(90)
scores.append(91)
print(scores)
print(scores[1])
# how do we remove the decimal point in the result of an array???
我们如何从数组的结果中删除小数点???
scores = array('d')
初始化双精度数组(由 表示'd'
)而不是整数。如果你想保存一个没有小数的值数组,你可以这样写一个数组array('i')
。
您可能还想查看可能适合您需要的其他数据类型。
如果您只想打印没有小数的值,您可以在打印时将它们转换为整数: print(int(scores[1]))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句