我希望Python能够做类似于MS Excel的功能:=ROUNDDOWN(number, num_digits)
。因此在我的例子中,看起来像这样:
a = [3.5, 43.689, 113.225, 65.4545]
我尝试过这样做:
a = [3.5, 43.689, 113.225, 65.4545]
b = [str(i).split(".") for i in a]
c = [i[0] for i in b]
d = [i[1][0] for i in b]
e = list(zip(c,d))
f = [float(".".join(i)) for i in e]
我需要的输出是:
>>> print (f)
[3.5, 43.6, 113.2, 65.4]
有没有更好、更简单的方法在Python中完成上述任务?