简体   繁体   English

float()参数必须是字符串或数字,而不是'zip'

[英]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.

相关问题 如何解决“ TypeError:float()参数必须为字符串或数字,而不是'zip'的错误” - how to solve the error of “TypeError: float() argument must be a string or a number, not 'zip'” float参数必须是字符串或数字 - float argument must be a string or a number float() 参数必须是字符串或数字,而不是 'Float' - float() argument must be a string or a number, not 'Float' TypeError:float()参数必须是字符串或数字,而不是“ NaTType” - TypeError: float() argument must be a string or a number, not 'NaTType' 类型错误:float() 参数必须是字符串或数字,而不是“列表” - TypeError: float() argument must be a string or a number, not 'list' TypeError:float()参数必须是字符串或数字 - TypeError: float() argument must be a string or a number 错误:float()参数必须是字符串或数字,而不是'AxesSubplot' - Error: float() argument must be a string or a number, not 'AxesSubplot' TypeError:float()参数必须是字符串或数字,而不是'IntVar' - TypeError: float() argument must be a string or a number, not 'IntVar' TypeError:float()参数必须是字符串或数字,而不是“ Timestamp” - TypeError: float() argument must be a string or a number, not 'Timestamp' TypeError:float()参数必须是字符串或数字,而不是“ tuple” - TypeError: float() argument must be a string or a number, not 'tuple'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM