文章内容
2018/12/22 13:45:11,作 者: 黄兵
TypeError: must be str, not int
最近在调试程序的时候,报如下错误:
TypeError: must be str, not int
具体出错代码如下:
phone_flag = 'sms_' + item + '_total' get_redis_count = redis_client.get(phone_flag)
出错原因:
item
是一个数字,数字和字符串组合没有转换,才会出现这个错误。
解决方案:
phone_flag = 'sms_' + str(item) + '_total' get_redis_count = redis_client.get(phone_flag)
问题解决。
参考资料:Python TypeError must be str not int [duplicate]
黄兵个人博客原创。
评论列表