Py学习  »  Python

将python for循环转换为一行代码

cget • 6 年前 • 2009 次点击  

如何将此for循环转换为一行代码?

numbers = []
for i in range(51):
    numbers.append(i)

print(numbers)

预期输出是包含1到50([1…50])的数字列表

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/52780
文章 [ 4 ]  |  最新文章 6 年前