Life is short, you need Python

字符串中的字符倒转

方法一,使用[::-1]:

= 'python'
print s[::-1]

 

方法二,使用reverse()方法:

= list(s)
l.reverse()
print ''.join(l)

 

输出结果:
nohtyp
nohtyp

作者:CoderZhCoderZh的技术博客 - 博客园
出处:
http://coderzh.cnblogs.com/

 

posted @ 2010-06-28 09:44  runfox545  阅读(379)  评论(0编辑  收藏  举报
白月黑羽 Python教程 白月黑羽Python