values = ['1', '2', '-3', '-', '4', 'N/A', '5']
def isNum(s):
try:
int(s)
return True
except:
return False
print(list(filter(lambda i: isNum(i), values)))
# 简写
print(list(filter(isNum, values))) # ['1', '2', '-3', '4', '5']
from itertools import compress
# 压缩?
print(list(compress(values, [isNum(i) for i in values]))) # ['1', '2', '-3', '4', '5']