# 类型错误：+ 不支持的操作数类型：'int' 和 'str'

- **ID:** `python/typeerror-unsupported-operand-type`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试函数尝试将整数和字符串相加，未经显式转换不允许。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |

## 解决方案

1. **Convert string to int before addition** (95% 成功率)
   ```
   result = 5 + int('3')
   ```
2. **Ensure type consistency in test data** (90% 成功率)
   ```
   a = 5; b = 3; result = a + b
   ```

## 无效尝试

- **Using str() on both operands** — Converts both to strings, resulting in concatenation instead of addition. (50% 失败率)
- **Using int() on string without validation** — If string is not numeric, int() raises ValueError. (60% 失败率)
