zl程序教程

您现在的位置是:首页 >  其它

当前栏目

TypeError: can only concatenate str (not “int“) to str,字符串和整数不能运算

字符串 to not 不能 运算 整数 can int
2023-09-27 14:20:36 时间

源代码:

错误:

错误原因:

是在处理end +1 这一步运算时,end变量的格式是字符串,而1是整数,在这里智能整数相加,所以处理是:

int(end) +1  即可解决问题