解决《Python编程:从入门到实践》17章中的一个报错:“AttributeError: 'NoneType' object has no attribute 'decode'”

《Python编程:从入门到实践》第17章,349页:


image.png

在输完上图代码之后运行代码后,报错如下:

metadata['label'])
return string.decode('utf-8')
AttributeError: 'NoneType' object has no attribute 'decode'

”空类型“对象没有属性“decode”
应该是label属性 期望是个字符串
将上图中箭头所指的那一行改为:

'label':str(respon_dic['description'])

加油!

你可能感兴趣的:(解决《Python编程:从入门到实践》17章中的一个报错:“AttributeError: 'NoneType' object has no attribute 'decode'”)