1 方法一,使用[::-1]:
 2 
 3 s = 'python'
 4 print(s[::-1])
 5 
 6 
 7 方法二,使用reverse()方法:
 8 
 9 n = list(s)
10 n.reverse()
11 print(''.join(n))
12 
13 results:
14 
15 nohtyp
16 nohtyp