在运行python代码时,遇到TypeError: can only concatenate str (not “Tensor”) to str的问题,根据其报错提示可知,本该使用字符串的类型却错误使用了tensor类型,故只要将该tensor类型转换为字符串类型即可。
常用转换方式为str()。
除此类报错外,还有TypeError: can only concatenate str (not “int”) to str,也是相同的解决方式。
在运行python代码时,遇到TypeError: can only concatenate str (not “Tensor”) to str的问题,根据其报错提示可知,本该使用字符串的类型却错误使用了tensor类型,故只要将该tensor类型转换为字符串类型即可。
常用转换方式为str()。
除此类报错外,还有TypeError: can only concatenate str (not “int”) to str,也是相同的解决方式。