iloc can only concatenate str (not "int") to str
时间: 2023-11-21 16:17:03 浏览: 156
ds3_loc_iloc:创建存储库以举例说明在数据集中使用loc和iloc
The error message "TypeError: can only concatenate str (not 'int') to str" occurs when you try to concatenate a string with an integer using the "+" in Python.
To resolve this error, you need to convert the integer to a string before concatenating it. Here's an example:
```python
x = 10
y = "The value of x is: " + str(x)
print(y)
```
This will output: "The value of x is: 10".
By using the `str()` function, we convert the integer `x` to a string before concatenating it with the other string.
阅读全文