来自https://stackoverflow.com/questions/12851791/removing-numbers-from-string
python3:
from string import digits
s = 'abc123def456ghi789zero0'
remove_digits = str.maketrans('', '', digits)
res = s.translate(remove_digits)
# 'abcdefghizero'
或者:
filter(lambda x: x.isalpha(), "a1a2a3s3d4f5fg6h")
还可以:
for i in range(10):
a.replace(str(i),'')
python2:
from string import digits
s = 'abc123def456ghi789zero0'
res = s.translate(None, digits)
# 'abcdefghizero'