为什么我在 Python 中得到错误的回溯?

问题描述

我收到一条错误消息,该消息在抓取网站获取以太坊价格的脚本中没有意义。

这是引发异常的地方:

        # part of a loop
        ....
        element = browser.find_element_by_css_selector(selector)
        data = element.text.split('\n')
        symbol,price = tuple(data[-2].split(' '))
        assert symbol == 'Ξ'
        total_price += float(price)
    price_list.append((total_price,dict_with_data))

# in top namespace
price_list.sort() #<-- the acual line that raised an exception

这是错误的回溯:

Traceback (most recent call last):
  File ...,line 142,in <module>
    assert symbol == 'Ξ'
TypeError: '<' not supported between instances of 'dict' and 'dict'

错误消息是正确的,我已经修复了它,但它说错误发生在 assert symbol == 'Ξ' 行中,这显然是错误的,因为它发生在 price_list.sort() 行中。为什么这个回溯给我虚假信息?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)