python3----字符串中的字符倒转

 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

 

 

 

posted @ 2018-01-11 18:08  jonm  阅读(446)  评论(0编辑  收藏  举报