您的位置: 首页 > 文章 > python错误、技巧集合(持续更新) python错误、技巧集合(持续更新) 分类: 文章 • 2024-11-25 19:45:46 知其然更知其所以然 文章目录 一.错误: 1.unsupported operand type(s) for |: 'str' and 'str' 一.错误: 1.unsupported operand type(s) for |: ‘str’ and ‘str’ “这个或运算符号 ‘’|‘’ 不能用在‘str‘ 类型之间”原因: 听报错就很明白了,此次进行了‘str’与‘str’的运算,即‘1’与end之间发生了计算 查找运算优先级发现 ‘|'的优先级比’== ’高,故会发生该错误。解决方法: a. 'and’也可以进行与运算,且优先级比”==“低 b.加括号