回文正序和逆序一样的字符串,例如abccba
方法一
def is_palindrome1(text): l = list(text) l.reverse() t1 = ''.join(l) if t1 == text: print 'the text is palindrome' else: print 'the text is not palindrome'
方法二
def is_palindrome2(text): t1 = text[::-1] if t1 == text: print 'the text is palindrome' else: print 'the text is not palindrome'
方法三
def is_palindrome3(text): r = True for x in range(len(text)): print x,text[x] if text[x] != text[len(text)-x-1]: print 1 r = False break if r == True: print 'the text is palindrome' else: print 'the text is not palindrome'