>> any(a in lowercase[i::j+1] for i,j in product(range(26),repeat=2))True>>> b..._python 字符串字母是否是升序">
赞
踩
>>> from itertools import product
>>> from string import lowercase
>>> a="abc"
>>> any(a in lowercase[i::j+1] for i,j in product(range(26),repeat=2))
True
>>> b="ceg"
>>> any(b in lowercase[i::j+1] for i,j in product(range(26),repeat=2))
True
>>> c="longer"
>>> any(c in string.lowercase[i::j+1] for i,j in product(range(26),repeat=2))
False
>>> d="bdfhj"
>>> any(d in string.lowercase[i::j+1] for i,j in product(range(26),repeat=2))
True
没有必要使用产品,而且这样做效率更高一些
>>> any(a in string.lowercase[i::j+1] for i in range(26) for j in range(26-i))
True
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。