How to round numbers

后端 未结 2 986
粉色の甜心
粉色の甜心 2021-01-22 02:58

How would I be able to round numbers like these to two decimal places which are all stored in a variable which has been outputted by a web scraper:

4.7532
4.7294         


        
2条回答
  •  执念已碎
    2021-01-22 03:04

    Use the built-in function round(), example:

    >>> round(4.7532,2)
    4.75
    >>> round(4.7294,2)
    4.73
    

提交回复
热议问题