Home > Backend Development > Python Tutorial > Python 字符串中的字符倒转

Python 字符串中的字符倒转

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-16 08:47:35
Original
1298 people have browsed it

方法一,使用[::-1]:
s = 'python'
print s[::-1]

方法二,使用reverse()方法:
l = list(s)
l.reverse()
print ''.join(l)
输出结果:
nohtyp
nohtyp

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template