Python 字符串中的字符倒转 2020-04-08 分类:Python 标签Tags:python,字符串,字符,倒转,方法,使用,s,print,reverse,l,list,join,输出,结果,n,ohtyp
方法一,使用[::-1]: s = 'python' print s[::-1] 方法二,使用reverse()方法: l = list(s) l.reverse() print ''.join(l) 输出结果: nohtyp nohtyp 以上就是【Python 字符串中的字符倒转】的全部内容了,欢迎留言评论进行交流!