今天将程序部署到linux服务器上,出现很奇怪的现象。

在windows上运行正常的decimal,到了linux环境下不能正常运行,报出下面的错误。

python中 decimal不能直接应用于float数据

 

代码为:

 income = get_dashboard_revenue(Project_id)
 TWOPLACES = Decimal(10)** -2
 key_metrics["income"] = Decimal(income).quantize(TWOPLACES)  

按照提示修改代码为:

 income = get_dashboard_revenue(Project_id)
 TWOPLACES = Decimal(10)** -2
 key_metrics["income"] = Decimal(str(income)).quantize(TWOPLACES)  

再运行,一切正常。

相关文章:

  • 2021-11-23
  • 2022-01-30
  • 2021-06-25
  • 2021-05-19
  • 2022-03-09
  • 2022-02-12
猜你喜欢
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2021-08-12
  • 2021-08-31
  • 2021-12-10
相关资源
相似解决方案