AttributeError: 'list' object has no attribute 'keys'
#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
AttributeError: 'list' object has no attribute 'keys'的更多相关文章
- AttributeError: 'dict' object has no attribute 'encode'
首先这是一个很简单的 运行时错误: 错误分析: AttributeError:属性错误,造成这种错误的原因可能有: 你尝试访问一个不存在的属性或方法.检查一下拼写!你可以使用内建函数 dir 来列出存 ...
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- AttributeError: 'list' object has no attribute 'write_pdf'
我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf' 我使用的是python3.4 from sk ...
- attributeError:'module' object has no attribute ** 解决办法
写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...
- AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'
/*************************************************************************** * AttributeError: 'modu ...
- AttributeError: 'dict_values' object has no attribute 'translate'
/***************************************************************************************** * Attribu ...
- python3 AttributeError: 'NoneType' object has no attribute 'split'
from wsgiref.simple_server import make_server def RunServer(environ, start_response): start_response ...
- 对于AttributeError: 'Flask' object has no attribute 'cli'的解决办法
版权声明:本文为博主原创文章,未经博主允许不得转载. 环境flask-script2.0.5.flask0.10.1 运行官方文档sample 出现问题 c:\kk\flask\examples\fl ...
- AttributeError: 'module' object has no attribute 'Thread'
$ python thread.py starting at: 2015-08-05 00:24:24Traceback (most recent call last): File "th ...
随机推荐
- 解决PHP Redis扩展无法加载的问题(zend_new_interned_string in Unknown on line 0)
出错代码如下 PHP Warning: PHP Startup: Unable to load 最近在工作中需要使用PHP访问Redis,从https://github.com/phpredis/ph ...
- IIS下配置跨域设置Access-Control-Allow-Origin
设置Access-Control-Allow-Origin 打开IIS,找到“HTTP响应标头”点进去, 在右侧可以看到添加,然后添加如下标头即可 Access-Control-Allow-Heade ...
- java数据结构 • 面向对象 • 异常 • 随机数·时间
• 语法基础 • 控制流 • 数据结构 • 面向对象 • 异常 • 随机数 //String常用的方法: indexOf charAt charAt codePointAt compa ...
- DAY9(PYTHON)
li=[{'usename':'xiaowang'}, {'} ] board=['张三','李四','王大麻子'] while 1: usename = input('用户名:') if usena ...
- 【转】c# [Serializable]的作用
http://blog.csdn.net/chinarenkai/article/details/3220452 如果你做远程方法调用(RPC)时,比如,服务器端有个类A及对象a,客户端需要无视网络的 ...
- matlab练习程序(点集配准的SVD法)
上一篇博客中我们使用了四元数法计算ICP. 本篇我们使用SVD计算ICP. 下面是<视觉slam十四讲>中的计算方法: 计算步骤如下: 我们看到,只要求出了两组点之间的旋转,平移是非常容易 ...
- Scala依赖注入
控制反转(Inversion of Control,简称IoC),是面向对象编程中的一种设计原则,可以用来降低计算机代码之间的耦合程度.其中最常见的方式叫做依赖注入(Dependency Inject ...
- [20181122]模拟ORA-08103错误.txt
[20181122]模拟ORA-08103错误.txt $ oerr ora 810308103, 00000, "object no longer exists"// *Caus ...
- shell编程-语句(八)
if else判断语句 if语句 语法格式1: if 条件 then 语句1 语句2 ... 语句n fi 语法格式2: 常用于终端命令提示符中 if [条件]:then 语句:fi if else语 ...
- js强制不使用“兼容性视图”
在IE8浏览器以后版本,都有一个“兼容性视图”,让不少新技术无法使用.那么如何禁止浏览器自动选择“兼容性视图”,强制IE以最高级别的可用模式显示内容呢?下面就介绍一段HTML代码. X-UA-Comp ...