TypeError: cannot concatenate 'str' and 'dict' objects

前端 未结 2 1213
情歌与酒
情歌与酒 2021-01-15 15:22

I am a novice in the field, and I wanted to create a program that was useful and fast handling, and run this script, I get this error, and I could not get this error.

<
相关标签:
2条回答
  • 2021-01-15 15:59
    web_response = {2L: 67.0, 3L: 13.67, 4L: 10.25, 5L: 11.8, 6L: 11.83}
    

    I've a dictionary named "web_response",For concatenation of dictionary with string I used comma ","

    print "web_response=", web_response
    

    Output:

    web_response= {2L: 67.0, 3L: 13.67, 4L: 10.25, 5L: 11.8, 6L: 11.83}
    
    0 讨论(0)
  • 2021-01-15 16:18

    the error message should be clear, you can't use + operator to sum a string and a dictionary, maybe you want to convert the dict to a string. If getFTPConfig('Pass') is returning a dictionary then

    str(getFTPConfig('Pass'))+"whatever"
    
    0 讨论(0)
提交回复
热议问题