如何将此数字转换为可以进行简单数学运算的整数?!(例如,低于 10.5200。)
{"bid":["10.52000000","0.70824000"],"ask":["10.54000000","2.07336000"],"seq":2456916}
我收到以下错误,这让我心烦意乱:
ValueError: invalid literal for int() with base 10: '10.52'
这就是我正在运行的:
bitfl = json.loads(bitfl)
bid = bitfl['bid']
ask = bitfl['ask']
bidd = bid[0] #edit - this is actually in, as it's a list
askk = ask[0]
print('diff: %i' % (int(bidd[0]) - int(askk[0])))
我不知道为什么只接受“10.52”作为字符串、浮点数或 unicode 并将其转换为正常的、可计算的整数会如此困难!
非常感谢任何帮助!