tuple 不能这样生成吗?
numbersInList = [x for x in range(10)] numbersInTuple = (x for x in range(10)) print(numbersInTuple) print(numbersInList)
结果是这样的:
<generator object <genexpr> at 0x0000025227369510>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
为什么不能生成Tuple?
numbersInList = [x for x in range(10)] numbersInTuple = (x for x in range(10)) print(numbersInTuple) print(numbersInList)
结果是这样的:
<generator object <genexpr> at 0x0000025227369510>
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
为什么不能生成Tuple?
2021-05-09
举报