所以在读取字典的时候,最好先判断类型,然后再查看它是否已经有这样的属性:
type(mydict) == type({})             #检查不是字典
如果是字典,再看看有没有这样的属性:mydict.has_key('mykey')  
1、 看看变量是否是字典   2、检查字典是否有对应的key值 
    if 'like' in condition:
cond_str1 = condition.split('like')[0].strip()
cond_str2 = condition.split('like')[1].strip()
print(staff_info)
ret = filter(lambda x:cond_str2 in str(x[cond_str1]), staff_info) # 这里字典写错

python报错 TypeError: string indices must be integers的更多相关文章

  1. TypeError: string indices must be integers, not str

    1. TypeError: string indices must be integers, not str 字符串类型取第index个字符的时候,应该传入int而不是str.如 1 a='abcde ...

  2. python报错 TypeError: a() got multiple values for argument 'name'

    [问题现象] 在一次调用修饰函数中出现了问题,折腾了一下午,一直报错 TypeError:  got multiple values for argument 只是很简单的调用 from tsu2Ru ...

  3. python 报错TypeError: 'range' object does not support item assignment,解决方法

    贴问题 nums = range(5)#range is a built-in function that creates a list of integers print(nums)#prints ...

  4. Python报错TypeError: '<' not supported between instances of 'str' and 'int'

    n = input() if n>=100:print(int(n)/10) else:print(int(n)*10) 报错内容: Traceback (most recent call la ...

  5. faster rcnn报错:TypeError: slice indices must be integers or None or have an __index__ method

    https://blog.csdn.net/qq_27637315/article/details/78849756 https://blog.csdn.net/qq_21089969/article ...

  6. for遍历用例数据时,报错:TypeError: list indices must be integers, not dict,'int' object is not iterable解决方法

    一:报错:TypeError: list indices must be integers, not dict for i in range(0,len(test_data)): suite.addT ...

  7. Python报错:TypeError: data type not understood

    K-Means聚类算法 def randCent(dataSet, k): m, n = dataSet.shape # numpy中的shape函数的返回一个矩阵的规模,即是几行几列 centrod ...

  8. appium 提示报错“TypeError: 'unicode' object is not callable”的解决方式!

    这里提到的这个报错,是小错误且容易经常会犯,有时需要特别注意使用. 目的要求结果:根据某个元素的id值获取到对应id的text值,并且将获取的text值与本身存在的text值做比较,查看text值是否 ...

  9. Python报错总结丶自定义报错

    Python报错总结: 常见异常 1,NameError: name 'a' is not defined:未定义函数名             2,IndentationError: uninden ...

随机推荐

  1. 苹果mac版微软官方远程连接工具下载Microsoft Remote Desktop For Mac

    官网beta版本,不用再到处找包了. ** 点我访问https://rink.hockeyapp.net/apps/5e0c144289a51fca2d3bfa39ce7f2b06/**

  2. js 闭包就是把值暂时保留在了内存里

    <script> function a(){ var i = 0; function b(){ alert(i++); } return b; } var c = a(); c(); c( ...

  3. 【c语言】将正数变成相应的负数,将负数变成相应的正数

    <pre name="code" class="cpp">// 将正数变成相应的负数,将负数变成相应的正数 #include <stdio.h ...

  4. (转)javascript日期格式化扩展

    转自:http://blog.csdn.net/vbangle/article/details/5643091 javascript Date format(js日期格式化)   方法一:这个很不错, ...

  5. this,你是谁?

    在js中this不像其它语言那样容易理解,它有时候指window对象,有时候又是其它对象,那么this,你到底是谁呢?要分析this就要先理解js中的方法定义,因为this一般都是在方法中使用的,而且 ...

  6. Spring工具类

    文件资源访问 1.统一资源访问接口 Resource 2.实现类 FileSystemResource 通过文件系统路径访问 ClassPathResource 通过classpath路径访问 Ser ...

  7. django数据库读写分离,分库

    读写分离 在settings中配置不同名称的数据库连接参数,并配置一条数据库选择路由 DATABASES = { 'default': { 'ENGINE': 'django.db.backends. ...

  8. 编写高质量代码--改善python程序的建议(四)

    原文发表在我的博客主页,转载请注明出处! 建议十八:有节制的使用from...import语句 python提供了三种方式引入外部模块: import语句 from...import... __imp ...

  9. c# public private protected internal protected internal

    一个 访问修饰符 定义了一个类成员的范围和可见性.C# 支持的访问修饰符如下所示: public:所有对象都可以访问: private:对象本身在对象内部可以访问: protected:只有该类对象及 ...

  10. where case 使用

    1 traceroleid表数据 tracerleid 表放着角色的相关信息, 角色ID 角色类型 密码 2 traceaccountmap表数据 表中存放着客户号和 其他角色的关系 tracerol ...