Python天天美味(8) - 字符串中的字符倒转

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

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

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

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

输出结果:
nohtyp
nohtyp

Python 天天美味系列(总)

Python 天天美味(6) - strip lstrip rstrip  

Python 天天美味(7) - 连接字符串(join %)  

Python 天天美味(8) - 字符串中的字符倒转

Python 天天美味(9) - translator  

Python 天天美味(10) - 除法小技巧

...
posted @   CoderZh  阅读(2146)  评论(2)    收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示