Python 我不知道';我不知道为什么';“我得到了”;类型错误:'<';在';str';和';int'&引用;错误

Python 我不知道';我不知道为什么';“我得到了”;类型错误:'<';在';str';和';int'&引用;错误,python,web-scraping,openpyxl,Python,Web Scraping,Openpyxl,我正在尝试创建一个跟踪程序,并使用BeautifulSoup和requests库来降低Steam网站的价格。然后使用openpyxl将这些价格值写入excel文件 在前四场比赛中,一切都完美无瑕。当我尝试将更多游戏标题添加到列表中时,出现了错误 请参见下面的代码 在我将空心骑士项目添加到wistlist数组后,我开始出现以下错误: TypeError:“如错误所述,问题已解决 看起来我在这里用json文件犯了一个令人畏惧的小错误 当我在json中添加其他项时,我意外地将值行编码为str-type

我正在尝试创建一个跟踪程序,并使用BeautifulSoup和requests库来降低Steam网站的价格。然后使用openpyxl将这些价格值写入excel文件

在前四场比赛中,一切都完美无瑕。当我尝试将更多游戏标题添加到列表中时,出现了错误

请参见下面的代码

在我将空心骑士项目添加到wistlist数组后,我开始出现以下错误:


TypeError:“如错误所述,
问题已解决

看起来我在这里用json文件犯了一个令人畏惧的小错误

当我在json中添加其他项时,我意外地将值行编码为str-type,而不是纯int

我们需要一个int值来定位excel工作表中的单元格,但我的代码值行是str类型的

我最好学会注意打字错误

感谢您的帮助和参与

{
  "titles": [
    {
      "name": "Human Fall Flat",
      "line": 6
    },
    {
      "name": "The Forest",
      "line": 6
    },
    {
      "name": "Garry's Mod",
      "line": 6
    },
    {
      "name": "Grand Theft Auto V",
      "line": 6
    },
    {
      "name": "Hollow Knight",
      "line": "2"
    },
    {
      "name": "Dead Cells",
      "line": "2"
    },
    {
      "name": "We Happy Few",
      "line": "2"
    },
    {
      "name": "Shovel Knight: Specter of Torment",
      "line": "2"
    },
    {
      "name": "Stardew Valley",
      "line": "2"
    }
  ]
}

请使用完整回溯发布整个错误消息。上面更新了完整回溯。您可能不使用任何比较,但正如您在回溯中看到的,openpyxl使用比较作为额外检查,这导致了您的错误。显然,
lines[i]
是一个
str
,但我们无法从您在此处发布的内容中确定。
lines[i] 
将是一个字符串,不能用于列号;请确保它是可以用作列号的正确整数。
  File "C:\Users\Han\AppData\Local\Programs\Python\Python37\lib\site-packages\openpyxl\worksheet\worksheet.py", line 236, in cell
    if row < 1 or column < 1:
TypeError: '<' not supported between instances of 'str' and 'int'
    if row < 1 or column < 1:
  File "c:/Python37/SteamTracker/main.py", line 58, in updateProducts
    sheet.cell(lines[i],2, value = float(price)) # updating cells
{
  "titles": [
    {
      "name": "Human Fall Flat",
      "line": 6
    },
    {
      "name": "The Forest",
      "line": 6
    },
    {
      "name": "Garry's Mod",
      "line": 6
    },
    {
      "name": "Grand Theft Auto V",
      "line": 6
    },
    {
      "name": "Hollow Knight",
      "line": "2"
    },
    {
      "name": "Dead Cells",
      "line": "2"
    },
    {
      "name": "We Happy Few",
      "line": "2"
    },
    {
      "name": "Shovel Knight: Specter of Torment",
      "line": "2"
    },
    {
      "name": "Stardew Valley",
      "line": "2"
    }
  ]
}