-2

假设我有这个列表 [[55.0][75.1]],我怎么能把它变成两个分开的整数变量5575 提前谢谢

4

2 回答 2

1
>>> from decimal import Decimal
>>> [int(Decimal(x[0])) for x in i]
[55, 75]

这是长版本:

results = []
for x in i:
   int_value = int(Decimal(x[0]))
   results.append(x)
于 2013-02-04T11:33:15.323 回答
0
k = []
k.append(55.0)
k.append(75.1)
l = [k]
print l

int0 = int(l[0][0])
int1 = int(l[0][1])
print int0
print int1

印刷:

[[55.0, 75.1]]
55
75
于 2013-02-04T11:29:35.327 回答