assignment 6.5

使用find方法和字符串切片,提取出字符串中冒号后面的部分,然后使用float函数,将提取出来的字符串转换为浮点数

代码如下:

1
2
3
4
text = "X-DSPAM-Confidence:    0.8475"
pos = text.find(':')
host = float(text[pos+1:])
print host