方法一,使用[::-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
Python 天天美味系列(总)
Python 天天美味(6) - strip lstrip rstripPython 天天美味(7) - 连接字符串(join %)
...
本文转自CoderZh博客园博客,原文链接:http://www.cnblogs.com/coderzh/archive/2008/05/03/1180584.html,如需转载请自行联系原作者