站长资源脚本专栏
Python 字符串中的字符倒转
简介方法一,使用[::-1]: s = 'python' print s[::-1] 方法二,使用reverse()方法: l = list(s) l.reverse() print ''.join(l) 输出结果: nohtyp nohtyp
方法一,使用[::-1]:
s = 'python'
print s[::-1]
方法二,使用reverse()方法:
l = list(s)
l.reverse()
print ''.join(l)
输出结果:
nohtyp
nohtyp
s = 'python'
print s[::-1]
方法二,使用reverse()方法:
l = list(s)
l.reverse()
print ''.join(l)
输出结果:
nohtyp
nohtyp
下一篇:Python备份Mysql脚本