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

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

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

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

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


输出结果:
nohtyp
nohtyp

原文地址:https://www.cnblogs.com/qq78292959/p/3066639.html