回文正序和逆序一样的字符串,例如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'

最新文章

  1. MyBatis在insert插入操作时返回主键ID的配置
  2. MailKit系列之---查询SearchQuery
  3. Windows 7您的凭据不工作
  4. 移动端WEB开发备忘录
  5. 如何在CentOS 7上安装EPEL源
  6. java执行时的两个常见问题(无法加载主类)
  7. C++多态分析(polymorphisn)
  8. ext4.0绘制chart(柱状图,条形图)
  9. JS作用域概念-预解析规则
  10. 字符通向字节流的桥梁---- OutputStreamWriter
  11. eclipse扩容
  12. flask学习(一)
  13. Spring Cloud 2-Hystrix 断路容错保护(四)
  14. Mad Libs 游戏
  15. DatetimeHelper,时间帮助类
  16. Django异常问题之Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。
  17. CentOS7 yum 安装 PHP 5.6.24
  18. Centos7部署ntp服务器同步时间以及直接将本地时间同步为北京时间
  19. UE4中多种颜色轮廓线的后期处理
  20. Android-序列化-Serializable/Parcelable

热门文章

  1. linux-一篇文章完成lnmp环境的编译安装
  2. Java多线程编程核心技术,第五章
  3. Vue 基本用法
  4. Bootstrap-Other:UI 编辑器
  5. SpringAOP的两种实现方式
  6. 性能基准测试:KVM大战Xen
  7. jQuery操作table tr td
  8. 新的方法(Set<T>)实现mvc的crud
  9. s2选择框的全选和反选jQuery
  10. Tutorial: Getting Started with Spring Security