将字符串翻转 # 1.倒序切片法 a = 'qwertyuiop' a = a[::-1] print(a) # 2.使用列表翻转在拼接 a = 'qwertyuiop' a = list(a) a.reverse() a = ''.join(a) print(a) # 3.循环反向迭代法 a = 'qwertyuiop' b = '' for i in a: b = i+b print(b) # 4.遍历索引法 a = 'qwertyuiop' b = '' for i in range(1,len(a)+1): b = b + a[-i] print(b) # 5.列表弹出法 a = 'qwertyuiop' a = list(a) b = '' while len(a)>0: b += a.pop() print(b)