Python_切割和查找

6.5 Write code using find() and string slicing (see section 6.10) to extract the number at the end of the line below. Convert the extracted value to a floating point number and print it out.(题目来源于书本"python for everybody")-COURSERA

text = "X-DSPAM-Confidence: 0.8475"
snum = float(text.find('0')) #23
real_num = text[int(snum):]
print(real_num)

posted @ 2018-03-20 13:27  solitude_26  阅读(150)  评论(0)    收藏  举报