一、格式化输出    {:.2f}

print("{:.2f}".format(1/6))

   python四舍五入保留2位小数

 

二、使用   round函数    round(a,2)    

round(1/6,2)

    python四舍五入保留2位小数

 

相关文章:

  • 2021-12-18
  • 2021-12-18
  • 2021-08-21
  • 2022-02-27
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案