列表推导式

num = [num for num in range(100) if num %2!=0]#只能获取为True的值

print(num)#获取100以内所有奇数

原文地址:https://www.cnblogs.com/lanxia/p/7997527.html