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日

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了