【问题标题】:Python TypeError: range() integer end argument expected, got floatPython TypeError:预期范围()整数结束参数,得到浮点数
【发布时间】:2013-04-19 02:21:53
【问题描述】:

我提前道歉,我看到已经给出了类似错误的答案,但我无法从我的案例中找出任何东西。我的 python 非常基础,我正在尝试运行那一小段代码:

mybox = (17.0, -13.0, 489.0644700903291, 566.0)
# this 'box' is my input so these values will vary

xMin, yMin, xMax, yMax = mybox

yValue = range(yMin, yMax, 30)

运行它,我得到一个错误:

TypeError: range() integer end argument expected, got float.

有没有办法在这样的范围内使用浮点数?

谢谢,

【问题讨论】:

标签: python python-3.x


【解决方案1】:

您正在寻找一个范围,可以在 numpy(或 pylab)中找到。

import numpy
...
yValue = numpy.arange(yMin, yMax, 30.0)

【讨论】:

    猜你喜欢
    • 2016-08-29
    • 2015-04-06
    • 2019-12-20
    • 1970-01-01
    • 2018-05-18
    • 1970-01-01
    • 2019-10-16
    • 1970-01-01
    相关资源
    最近更新 更多