代码:
# open some file
for line in fp:
list = line.strip().split();
list = str(data_list);
print(list[0]);
我的输出:
[
预期输出:2,500,000.00
some other number, only first item in every list
在我的清单中:
['2,500,000.00', '—', '2,999,999.99', '6,871', '158,164,946', '99.98619', '18,747,446,313.27', '2,728,488.77']
and more......
答案 0 :(得分:1)
那是因为它不是一个清单。您正在将列表转换为字符串:
list = str(data_list);
print(list[0]);
,删除它,它应该可以正常工作。