检查字符串是否为回文

5年以前  |  阅读数:441 次  |  编程语言:Python 

以下函数用于检查字符串是否为回文。

def palindrome(string):
    return string == string[::-1]

palindrome('python') # False

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8