str类型python并没有reverse函数。 然而,通过反向步进切片,我们可以高效地反转一串字符串。 仅支持英文字符。 例: 1 a = 'example' 2 b = a[::-1] 3 print(b) 4 #输出结果'elpmaxe'