How to convert the first 4 characters of the below string to a float in python?
p="11.04GET /update?api_key=Q6BCBDA"
Thanks
Note that 1st 4 characters is "11.0" if you want "11.04" you need 5 characters
To get substring, you can use p[0:5]
To convert then to float you can use float(p[0:5])
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.