Discuss / Python / 作业

作业

Topic source

def is_palindrome(n): return str(n)==str(n)[::-1]

output = filter(is_palindrome, range(1, 1000)) print(list(output))

感觉不看评论好多函数的具体操作不会写,[::-1]的作用经测试是把字符串颠倒过来。 这些东西哪里可以看到?

吖龍灬灬

#2 Created at ... [Delete] [Delete and Lock User]

[::-1]这个是python切片的用法,此处可理解为在整个字符串中从尾开始取值


  • 1

Reply