字符串
字符串反转
1、while循环
str01 = "hello"
i=len(str01)-1
s='' while i>=0: s+=str01[i] i-=1 print(s)
2、字符串切片
str01 = "hello"
print(str01[::-1])
3、列表函数
str01 = "hello"
str02=list(str01)
str02.reverse()
print(''.join(str02))
str01 = "hello"
i=len(str01)-1
s='' while i>=0: s+=str01[i] i-=1 print(s)
str01 = "hello"
print(str01[::-1])
str01 = "hello"
str02=list(str01)
str02.reverse()
print(''.join(str02))