报错信息是TypeError: can only concatenate str (not "int") to str。这是因为len(li_list)返回的是一个整数,而不是字符串。你需要将其转换为字符串后再进行拼接,可以使用str()函数将整数转换为字符串。修改代码如下:

print("一级" + str(len(li_list)) + target)
print一级+lenli_list+target报错

原文地址: https://www.cveoy.top/t/topic/h9kM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录