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 ...
随机推荐
- WPF,强制捕获鼠标事件,鼠标移出控件外依然可以执行强制捕获的鼠标事件
在WPF中,只有鼠标位置在某个控件上的时候才会触发该控件的鼠标事件.例如,有两个控件都注册了MouseDown和MouseUp事件,在控件1上按下鼠标,不要放开,移动到控件2上再放开.在这个过程中,控 ...
- vim打开不同的文件
sp vim -o file1 file2 纵向打开文件 Ctrl+w Ctrl+v vim -O file1 file2 横向打开文件
- Java8 使用stream实现各种list操作
利用java8新特性,可以用简洁高效的代码来实现一些数据处理. 定义1个Apple对象: public class Apple { private Integer id; private String ...
- vue过滤器用法实例分析
过滤器: vue提供过滤器: capitalize uppercase currency.... ? 1 2 3 <div id="box"> {{msg|cu ...
- 微信小程序 table 简单测试
<view class='AutoTable'> <view id='AutoTableItem'> <block wx:for="{{array}}" ...
- BZOJ3453: tyvj 1858 XLkxc(拉格朗日插值)
题意 题目链接 Sol 把式子拆开,就是求这个东西 \[\sum_{i = 0} ^n \sum_{j = 1}^{a + id} \sum_{x =1}^j x^k \pmod P\] 那么设\(f ...
- 2018-06-20 中文代码示例视频演示Python入门教程第三章 简介Python
知乎原链 Python 3.6.5官方入门教程中示例代码汉化后演示 对应在线文档: 3. An Informal Introduction to Python 不知如何合集, 请指教. 中文代码示例P ...
- Spring IOC/DI
IOC:反转控制(资源获取),之前开发是要什么就 new 什么,现在只需创建 IOC 容器,你要什么 IOC 都会给你,你只管接收.反转控制的对象是 Bean,也就是对象 DI:依赖注入,依赖容器把资 ...
- Android gradle实现多渠道号打包
在build.gradle中添加 productFlavors{ LETV { applicationId "×××××××××××" //包名 buildConfigFiel ...
- Java相关问题整理
1. OkHttpClient调用出现大量CLOSE_WAIT. 问题定位: 凡是系统中出现大量的CLOSE_WAIT,说明你的代码写的有问题,即:没有关闭连接. 在OkHttpClient中,默认时 ...