字符串中的字符倒转
方法一,使用[::-1]:
s = 'python'
print s[::-1]
print s[::-1]
方法二,使用reverse()方法:
l = list(s)
l.reverse()
print ''.join(l)
l.reverse()
print ''.join(l)
输出结果:
nohtyp
nohtyp
作者:CoderZh(CoderZh的技术博客 - 博客园)
出处:http://coderzh.cnblogs.com/
Work for fun,Live for love!