反转字符串

Demo

#!/usr/bin/python3
st="haihong"
#方法1
print(''.join(reversed(st)))
#方法2
print(st[::-1])

运行结果

Python学习笔记(44)~反转字符串_python