Python 3 中未定义名称“xrange"

2022-01-24 00:00:00 python python-3.x range xrange

问题描述

我尝试执行以下代码,但无法执行错误:未定义名称xrange"

I try to execute following code but can't with mistake: name 'xrange' is not defined

pages = (
    requests.get(
        build_group_request({
            "offset": WINDOW_SIZE * i,
            "count": WINDOW_SIZE,
            "fields": "sex,interests,bdate"
        })
    ).json()['response']['items']
    for i in xrange(int(float(COUNT) / 100 + 1))
)


解决方案

你可能使用的是 Python3,其中 xrange 已变成 range.

You're probably using Python3, where xrange has become range.

相关文章