[Python]filter-获取回数

def is_palindrome(n):
    theStr = str(n)
    theStr2 = ''
    for char in theStr:
        theStr2 = char + theStr2
    if theStr2 == theStr:
        return True
    else:
        return False

print filter(is_palindrome, range(1, 1000))

你可能感兴趣的:([Python]filter-获取回数)