math.ceil()
1.这个只接受一个真正的数!!!!!
2.这样会报错:TypeError: must be real number, not list
import math as ma list1 = [1,1.2,3,4,5,6.7] ma.ceil(list1)
3.办法:循环追加;
import math as ma list1 = [1,1.2,3,4,5,6.7] list2 = [] for i in list1: x = ma.ceil(i) list2.append(x) print(list2)
#输出:[1, 2, 3, 4, 5, 7]