a = [s for s in range(3,101)[::2] if not [y for y in range(2,s) if s%y == 0]] print a
利用if not 判断其因子集合是否是空python
素数的因子集合为空code
条件句式 (if not 空List) 判断结果为True,于是该数就是素数。class