>>> d = ["his car number is ka99ap9999", "bike that met with accident is kl8ar888"]
>>> [w for s in d for w in s.split() if any(c.isalpha() for c in w) and any(c.isdigit() for c in w)]
['ka99ap9999', 'kl8ar888']
d = ["his car number is ka99ap9999", "bike that met with accident is kl8ar888"]
for i in d:
for x in i.split(' '):
if x.isalnum() and not x.isalpha() and not x.isdigit():
print x
似乎您正在查找
any
字符isdigit
and
any
字符isalpha
的单词。只要把它放在一个列表中,你就完成了:正如Willem Van Onsem所提到的,“车”也是字母数字的。你知道吗
要获得
ka99ap9999
作为输出,首先检查每个单词是否为字母数字,然后检查它是否仅为字母和数字。你知道吗代码:
相关问题 更多 >
编程相关推荐