龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > python编程 >

Python 字符串中的字符倒转

时间:2014-05-18 15:52来源:网络整理 作者:网络 点击:
分享到:
实现字符倒转的python函数
方法一,使用[::-1]:
s = 'python'
print s[::-1]

方法二,使用reverse()方法:
l = list(s)
l.reverse()
print ''.join(l)
输出结果:
nohtyp
nohtyp
精彩图集

赞助商链接