The numbers in the python list retain integers

You can use the built-in round() function to preserve integers, for example: list_ = [1.2,2.7,3.6] list_ = [round(num) for num in list_] print(list_) # output [1, 3, 4]

Guess you like

Origin blog.csdn.net/weixin_42588555/article/details/129604504