In [115]: def to_alphanum(text):
...: return ''.join([char for char in text if char.isalnum()])
...:
In [116]: to_alphanum('Cats go meow')
Out[116]: 'Catsgomeow'
In [117]: to_alphanum('#$')
Out[117]: ''
In [118]: to_alphanum('190 $%6')
Out[118]: '1906'
str
有isalnum
方法来检查字母数字,利用:相关问题 更多 >
编程相关推荐