文章内容

2021/1/19 17:46:12,作 者: 黄兵

TypeError: can only concatenate str (not "int") to str

在调试程序的时候出现如下错误:

TypeError: can only concatenate str (not "int") to str

出现问题的原因:

只能将str(而不是“ int”)连接到str,具体错误代码如下:

for item in range(int(start_ip), int(end_ip + 1)):

start_ipend_ip都是str数据类型,问题出现在:end_ip+1,1是int类型的,int和str连接操作,报上面的错误。

解决方案:

修改代码如下:

for item in range(int(start_ip), int(end_ip) + 1):

这里是做的加法运算。


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - TypeError: can only concatenate str (not "int") to str

分享到:

发表评论

评论列表