code:
# open some file
for line in fp:
list = line.strip().split();
list = str(data_list);
print(list[0]);
My output:
[
Expected Output: 2,500,000.00 some other number, only first item in every list
In my 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......
That's because it's not a list. You are converting list into a string:
list = str(data_list);
print(list[0]);
, remove it and it should work fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.