【问题标题】:Pycharm - Cannot find reference 'keys' in 'int|float|complex'Pycharm - 在“int|float|complex”中找不到引用“keys”
【发布时间】:2018-05-26 01:32:14
【问题描述】:

在 Pycharm 中,我得到 Cannot find reference 'keys' in 'int|float|complex'Cannot find reference '[' in 'int|float|complex' 用于以下几行。我该如何解决?我坚持要修复它!

dictionary = np.load(path2sink + 'dict.npy').item()
keys = [k for k in dictionary.keys() if dictionary[k] < threshold]

【问题讨论】:

  • dictionary的类型和值是什么?看看使用调试器。
  • 您确定不想:dictionary = np.load(path2sink + 'dict.npy').items() 吗?
  • @F.Leone 我想找回之前保存的字典。

标签: python python-3.x numpy pycharm


【解决方案1】:

dictionary = np.load(path2sink + 'dict.npy')[()],这段代码在pycharm中不会显示“Cannot find reference keys int| float|complex”。

【讨论】:

  • .item() 类似于 [()] 。不知道为什么问题会因为改变而得到解决
  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
  • 在我的 pycharm 中,.item() 会显示“找不到引用键 int| float|complex”,但 [()] 一切正常。
猜你喜欢
  • 2018-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-10
  • 1970-01-01
  • 2020-05-15
  • 2021-10-10
  • 2011-04-24
相关资源
最近更新 更多