python 去除数字

def is_hex(word):
    word= word.lower()
    for i in range(len(word)):
        if not( word[i].startswith('0x') or word[i].isdigit() or word[i] in ['a','b','c','d','e','f']):
            return False
    return True

def is_not_num(x):
    return not( len(x) > 0 and (x.isnumeric() or x[0].isdigit() or is_hex(x)) )

res = filter(is_not_num, str.split())  # 返回的是迭代器,list(res)
res = ''.join(filter(is_not_num, str.split()))

posted @ 2021-01-19 11:20  该显示昵称已被使用了  阅读(490)  评论(0编辑  收藏  举报