连接字符串然后打印

Bil*_*mus 4 python string string-concatenation

print ("Tag Value " + i.tags.get('Name'))
Run Code Online (Sandbox Code Playgroud)

给我:

  File "./boto_test.py", line 19, in main
    print ("Tag Value" + i.tags.get('Name'))
TypeError: cannot concatenate 'str' and 'NoneType' objects
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?

ker*_*rim 11

或者只是转换无论你geti.tags字符串:

print ("Tag Value " + str(i.tags.get('Name')))
Run Code Online (Sandbox Code Playgroud)