m0_71814277 2022-06-16 05:57 采纳率: 100%
浏览 103
已结题

这个程序如何用Python 语言编写

Write a program that categorizes each mail message by which day of the week the commit was done. To do this look for lines that start with “From”, then look for the third word and keep a running count of each of the days of the week. At the end of the program print out the contents of your dictionary (order does not matter).

img

麻烦给出一个完整的程序

  • 写回答

3条回答 默认 最新

  • A Python 萌新花花 2022-06-16 08:17
    关注
    file = input("name: ")
    with open(file,"r") as f:
        read = f.readlines()
    read = [i.split() for i in read]
    reee = []
    
    for i in read:
        if i[0] == "From":
            reee.append(i)
    
    dic = {}
    
    for i in reee:
        if i[2] == "Mon":
            dic[i[2]] = dic.get(i[2],0)+1
        if i[2] == "Tue":
            dic[i[2]] = dic.get(i[2],0)+1
        if i[2] == "Wed":
            dic[i[2]] = dic.get(i[2],0)+1
        if i[2] == "Thu":
            dic[i[2]] = dic.get(i[2],0)+1
        if i[2] == "Fri":
            dic[i[2]] = dic.get(i[2],0)+1
        if i[2] == "Sat":
            dic[i[2]] = dic.get(i[2],0)+1
        if i[2] == "Sun":
            dic[i[2]] = dic.get(i[2],0)+1
    print(dic)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 6月24日
  • 已采纳回答 6月16日
  • 赞助了问题酬金10元 6月16日
  • 创建了问题 6月16日

悬赏问题

  • ¥100 支付宝批量检测实名工具
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题