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

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

 

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

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


输出结果:
nohtyp
nohtyp

posted on 2013-05-08 13:44  一个人的天空@  阅读(183)  评论(0编辑  收藏  举报