a2509727141 2019-12-23 22:09 采纳率: 0%
浏览 859

用Python统计每个单词出现的个数,具体要求如图?

图片说明
求完整代码,各路神仙救救孩子吧...

  • 写回答

1条回答 默认 最新

  • 爱电摇的小码农 2023-11-14 17:36
    关注
    string = "A computer is a device that can be nstructed to carry out an atbitrary set of arithmetic or logical operations automaticaly.The ability of computers to follow a sequence of operations, called a program, make computers very flexible and useful.Such computers are used as control systems for a very wide variety of industrial and consumer devices. This includes simple special purpose devices like microwave ovens and remote controls, factory devices such as industrial robots and computer assisted design, but also in general purpose devices like personal computers and mobile devices such as smartphones . The Internet is run on computers and it connects millions of other computers ."
    the_list = []
    for x in string.split():
        if x not in the_list:
            the_list.append(x)
    print(the_list)
    item_count = []
    for y in the_list:
        item_count.append(string.count(y))
    print(item_count)
    

    不知道这段代码能不能帮到你

    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现