Study Notes (04): Python Interview 100 talking about (based Python3.x) - How to Reverse a string

Learning immediately: https://edu.csdn.net/course/play/26755/340115?utm_source=blogtoedu

Reverse string:

s1 = 'abcde'

s2=''

for c in s1:

    s2=c+s2

print(s2)

 

Reverse text fragment

Setting step -1

print(s1[::-1])

Released seven original articles · won praise 0 · Views 3279

Guess you like

Origin blog.csdn.net/zhaoxiaozheng1987/article/details/104246674