【问题标题】:TypeError: __new__() got an unexpected keyword argument 'load'TypeError: __new__() 得到了一个意外的关键字参数 'load'
【发布时间】:2020-11-16 09:13:23
【问题描述】:

TypeError Traceback(最近一次调用最后一次) 在

1 slt = SortedList(load = 1000)
      2 assert slt._load == 10000
      3 assert slt._twice == 20000
      4 assert slt._half == 5000
      5 slt._check()

TypeError: new() 得到了一个意外的关键字参数 'load'

【问题讨论】:

  • 为什么我会出错在这我引用了这个programcreek.com/python/example/90730/…
  • 如果我得到了正确的文档SortedList 需要一个可迭代和可选的键,而不是“加载”。
  • 哦等等,在这个例子中,它的SortedListWithKey 有“load”参数。
  • 还是不行
  • 22 votes = {} 23 for _,v in sl: ---> 24 votes[v] = votes.get(v, 0) + 1 25 max_votes = 0 26 max_votes_class= -1 TypeError: unhashable type: 'matrix'

标签: python sortedcontainers


【解决方案1】:

这可能来得有点晚,但似乎 sortedcontainers 中的 load 参数已从更高版本中删除。它应该仍然适用于 1.5.7 版。

https://github.com/mcocdawc/chemcoord/issues/54

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-15
    • 1970-01-01
    • 2016-09-17
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多