这是什么样的输出:<生成器对象<genexpr>位于0x03D63470>?

时间:2019-09-22 13:37:33

标签: python python-3.x

我试图使用循环输出一系列字符串。我的方法是从一个空列表开始,然后连续追加。

t = int(input())

i = 1

while i <= t:
    b = int(input())
    data = [int(n) for n in input().split()]

    data.sort() #orders the elements in ascending order
    l = data[0] #lowest value
    last = max(data) #highest value

    lh = []
    for j in range(l , last, b):
        h = j + b - 1
        lh.append(str(j) + " - " + str(h) for a in data)

    #a loop that goes through each elements
    for intervals in lh:
        print(intervals)


    i += 1

相反,这就是我得到的:

<generator object <genexpr> at 0x03BB44F0>
<generator object <genexpr> at 0x03BB4470>
<generator object <genexpr> at 0x03BB4430>
<generator object <genexpr> at 0x03BB43F0>
<generator object <genexpr> at 0x03BB4630>
<generator object <genexpr> at 0x03BB45F0>
<generator object <genexpr> at 0x03BB45B0>

如何将它们转换为字符串?

0 个答案:

没有答案