Python For Everybody 练习题解7.2

Python For Everybody 练习题解7.2,第1张

PForE_7.2

fname = input("Enter file name: ")
fh = open(fname)
count = 0
total = 0
for line in fh:
    if not line.startswith("X-DSPAM-Confidence:"):
        continue
    count = count + 1
    number = line[19:]
    number = number.rstrip()
    number = float(number)
    total = number + total
average = total/count
print("Average spam confidence:",average)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/568088.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-09
下一篇 2022-04-09

发表评论

登录后才能评论

评论列表(0条)

保存