相关疑难解决方法(0)

Python 3.x的字典视图对象和matplotlib

在蟒蛇3.X keys(),values()items()返回意见.现在虽然视图肯定有优势,但它们似乎也会导致一些兼容性问题.例如matplotlib(最终是numpy).作为一个例子对stackexchange问题的答案只是正常工作与Python 2.x的,但在Python 3.4执行他们的时候抛出一个异常.

一个最小的例子是:

import matplotlib.pyplot as plt
d = {1: 2, 2: 10}
plt.scatter(d.keys(), d.values())
Run Code Online (Sandbox Code Playgroud)

哪个TypeError: float() argument must be a string or a number, not 'dict_values'用python 3.4 引发.

虽然对于最小的例子,Exception非常清楚,但是由于同样的问题而出现了这个问题,而且这里的Exception不太清楚:TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' …

python numpy matplotlib python-3.x

14
推荐指数
1
解决办法
3087
查看次数

标签 统计

matplotlib ×1

numpy ×1

python ×1

python-3.x ×1