result = func(left, right) TypeError: unsupported operand type(s) for -: 'str' and 'str'
时间: 2024-01-29 22:02:22 浏览: 157
This error message indicates that you are trying to subtract two strings from each other, which is not a valid operation.
To fix this error, you need to make sure that both the left and right arguments passed to the function are numeric values (integers, floats, etc.) that can be subtracted from each other. If the inputs are strings that represent numbers, you can convert them to the appropriate numeric data type using functions like int() or float().
相关问题
Exception in Tkinter callback Traceback (most recent call last): File "D:\python\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "D:\桌面\mx_B\March\高景报料界面.py", line 52, in auto_insert1 cursor.execute(cursor.execute, param) File "D:\python\lib\site-packages\pymysql\cursors.py", line 146, in execute query = self.mogrify(query, args) File "D:\python\lib\site-packages\pymysql\cursors.py", line 125, in mogrify query = query % self._escape_args(args, conn) TypeError: unsupported operand type(s) for %: 'method' and 'tuple'
这是一个 Python 的错误信息,出现在 Tkinter 的回调函数中。具体来说,是在执行 pymysql 的 execute 函数时出现了错误。可以看到,错误信息中提到了一个 unsupported operand type(s) for %: 'method' and 'tuple',这说明在执行 SQL 查询时出现了错误。可能是参数传递的方式不正确,或者是 SQL 查询语句本身存在问题。建议检查代码中的参数传递方式和 SQL 查询语句的语法是否正确。
Traceback (most recent call last): File "C:\Users\HP\Desktop\Stone Crack\yolov5代码包\yolov5-master\yolov5-master\calllogin.py", line 343, in detect self.main(paraments) File "C:\Users\HP\Desktop\Stone Crack\yolov5代码包\yolov5-master\yolov5-master\calllogin.py", line 335, in main self.run(**vars(self.opt)) File "C:\Users\HP\anaconda3\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "C:\Users\HP\Desktop\Stone Crack\yolov5代码包\yolov5-master\yolov5-master\calllogin.py", line 174, in run model = DetectMultiBackend(weights, device=self.device, dnn=self.dnn, data=self.data, fp16=self.half) File "C:\Users\HP\Desktop\Stone Crack\yolov5代码包\yolov5-master\yolov5-master\models\common.py", line 301, in __init__ fp16 &= (pt or jit or onnx or engine) and device.type != 'cpu' # FP16 TypeError: unsupported operand type(s) for &=: 'tuple' and 'bool'
这个错误是由于在 `models/common.py` 文件的 `__init__` 方法中,执行按位与(&=)操作时,操作数的类型不一致引起的。
根据错误信息,我们可以看到错误发生在 `fp16 &= (pt or jit or onnx or engine) and device.type != 'cpu'` 这一行代码。
要解决这个问题,您可以尝试使用以下代码重写该行:
```python
fp16 = fp16 and (pt or jit or onnx or engine) and device.type != 'cpu'
```
请确保在执行按位与操作之前,操作数的类型是一致的。如果问题仍然存在,请检查相关变量的类型和值,并确保它们符合预期。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)