为什么是:
print([float(a.get_text()) for a in cb.ax.xaxis.get_ticklabels()])
给我:
ValueError: could not convert string to float: '−4.0'
其中 cb 是 ColorBar 的实例
请您参考如下方法:
粘贴您的文本:
>>> a = "−4.0"
>>> ord(a[0])
8722
>>> ord("-")
45
>>>
您在您的代码或界面中粘贴了“错误的”连字符/减号字符(一些替代的稍长的 unicode 字符)。 Python 无法解析它。
