回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页

[求助问答]TypeError: unsupported operand type(s) for -: 'str' and 'int'是什么意思? 中等

头像 UP0omFgMpGpt 2024.04.04 25 3


我写了一个解题器,代码如下:
import time



while True:
    print("欢迎使用三角形数表解题器")
    time.sleep(1)
    hang = input("请输入行")
    lie = input("请输入列")
    print((((hang + lie) - 1) * ((hang + lie) - 1)))
可运行了一半后,出现;

欢迎使用三角形数表解题器请输入行12请输入列3Traceback (most recent call last):  File "C:\Users\Administrator\Documents\mindplus-py\user\2024-03-31-11-58-03\11111.py", line 10, in <module>    print((((hang + lie) - 1) * ((hang + lie) - 1)))TypeError: unsupported operand type(s) for -: 'str' and 'int'




怎么办????????

评论

user-avatar
  • 三春牛-创客

    三春牛-创客2024.04.21

    TypeError: unsupported operand type(s) for -: 'str' and 'int' TypeError:不支持的操作数类型-:'str'和'int'

    0
    • 三春牛-创客

      三春牛-创客2024.04.21

      数值类型不对

      0
      • DFEDU

        DFEDU2024.04.07

        先把变量转成int类型的数据,再去做加减乘除运算。

        0