[英]float() argument must be a string or a number, not 'zip'
There is no problem when I run in python 2.7 but I am getting error when I run in python 3. 我在python 2.7中运行时没有问题,但是当我在python 3中运行时遇到错误。
Is there something that I need to change in this code. 我需要在此代码中更改某些内容。
import matplotlib as mpl
poly = mpl.path.Path(zip(listx,listy))
error that I am getting is 我得到的错误是
TypeError: float() argument must be a string or a number, not 'zip'
This is because in python2 zip()
returns a list of tuples, which mpl.path.Path()
happily accepts. 这是因为在python2中, zip()
返回一个元组列表, mpl.path.Path()
乐意接受它。 In python3, zip()
returns an iterator , which you must consume. 在python3中, zip()
返回一个必须使用的迭代器 。 You should be able to do something like: 你应该可以这样做:
>>> poly = mpl.path.Path(list(zip(listx, listy)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.