简体   繁体   中英

Converting\ joining a list into a float

by scraping a website I managed to get what i wanted, '2' '.' '7' '8' I've put them in a list. Now i want them all to be joined as a float 2.78

Can someone suggest something?

Thank You

I cannot join the decimal point to the number.

You can simply join them with join() function.

l=['2' '.' '7' '8']
float(''.join(l))

#output
2.78

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM