所以在读取字典的时候,最好先判断类型,然后再查看它是否已经有这样的属性:
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. 运行jsp需要安装_______Web服务器。

    运行jsp需要安装_______Web服务器. A.Apache B.tomcat C.WebLogic D.IIS 解答:BC Apache是PHP程序运行的服务器,IIS是.net程序运行的服务器 ...

  2. java网络编程4-ServerSocket

    //端口号为0则系统随机分配端口,连接队列系统一般默认50,指过超过系统最大的就以系统为准 //如果客户端的连接超过连接队列,则会被主机拒绝 ServerSocket serverSocket=new ...

  3. Ubuntu安装qBittorrent

    qBitTorrent是Ubuntu Linux中最受欢迎的P2P软件之中的一个. 出自一名法国大学生之手的qBitTorrent功能强大.界面精美.操作直观. qBitTorrent是Linux中最 ...

  4. Android 7.1.1 锁屏界面启动流程

    前几天遇到一个低概率复现锁屏界面不显示,仅仅显示状态栏的问题,跟了下锁屏界面启动显示的流程,在这分享下,也方便以后自己查看.前面简介了下Zygote启动流程, Zygote进程启动后会首先创建一个Sy ...

  5. Hadoop格式化HDFS报错java.net.UnknownHostException: centos64

    异常描述 在对HDFS格式化,执行hadoop namenode -format命令时,出现未知的主机名的问题,异常信息如下所示: [shirdrn@localhost bin]$ hadoop na ...

  6. mysql通过拷贝文件实现数据快速迁移实例

    最近在做监控DB的迁移,由于数据量非常大,采用直接拷贝从机数据目录的方式,操作过程有几个注意事项,记录下来,以备后用: 操作步骤: 1.停掉从机的SQL线程,并将 innodb_max_dirty_p ...

  7. 用vector构造自动扩容的二维数组

    #include <iostream> #include <string> #include <vector> using namespace std; int m ...

  8. Oracle数据库 number 长度与 Short Integer Long BigDecimal 对应关系

    转自:https://blog.csdn.net/edward9145/article/details/21398657 Oracle数据库 number 长度与 Short Integer Long ...

  9. HttpURLConnection 当作请求调用接口不带返回参数的工具类

    package cn.smartercampus.core.util; import java.io.BufferedReader; import java.io.InputStream; impor ...

  10. Nginx/LVS/HAProxy 负载均衡软件的优缺点对比

    Nginx/LVS/HAProxy是目前使用最广泛的三种负载均衡软件,一般对负载均衡的使用是随着网站规模的提升根据不同的阶段来使用不同的技术,具体的应用需求还得具体分析. 如果是中小型的Web应用,比 ...