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]

 

posted @ 2020-03-17 13:26  落月_YU  阅读(994)  评论(0编辑  收藏  举报