AttributeError: 'list' object has no attribute 'keys'
List 39 No object has attribute AttributeError
2023-09-11 14:21:24 时间
#encoding=utf-8 import os result = {} if os.path.exists("test.txt"): day_file = open("test.txt").read() day_file_list = day_file.split(" ") for i in day_file_list: # print "i: s" + str(i) + "e" if i == "#" or " ": day_file_list.remove(i) #continue if i not in result: result[i] = 1 else: result[i] = result[i] + 1 # print "result i: " + str(result[i]) result = sorted(result.items(), key = lambda item: item[1], reverse=True) for k in result.keys(): print result[k]
解决方案:
for i in result: print i
相关文章
- List 的一个有用的高效的操作 removeAll
- 使用迭代器遍历List的时候修改List报ConcurrentModificationException异常原因分析
- Java中List,Set,Map的区别以及API的使用
- python list插入、拼接
- Python实现比较两个列表(list)范围
- [Python's] Python's list comprehensions a
- [GraphQL] Use GraphQL's List Type for Collections
- GVM 21.4.3 Failed to find port_list '33d0cd82-57c6-11e1-8ed1-406186ea4fc5'
- 【经验】STL的list vector在iterator迭代器的循环中 使用erase 造成的BUG
- [GraphQL] Use GraphQL's List Type for Collections
- Python3成员运算符(List元素是否存在)
- json串 转 list<class> 方法 List转JSONArray和JSONArray转List String 转List
- Another reason why Opportunity list is empty
- Atitit s2018 s3 doc list alldvc.docx .docx s2018 s3f doc compc s2018 s3f doc homepc sum doc dvcCompc dtS312 s2018 s3f doc compcAtitit PathUtil 工具新特性新版本 v8 s312.docx s2018 s3f doc compcAtitit 操作日
- Atitit s2018.2 s2 doc list on home ntpc.docx Atiitt uke制度体系 法律 法规 规章 条例 国王诏书.docx Atiitt 手写文字识别 讯飞科大 语音云.docx Atitit 代码托管与虚拟主机.docx Atitit 企业文化 每日心灵 鸡汤 值班 发布.docx Atitit 几大研发体系对比 Stage-Gat
- Atitit.attilax的 case list 项目经验 案例列表
- flutter List和Map
- List<?> list= new ArrayList<?>接口引用指向实现类的对象.