码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-01-11 19:16:14      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:log   body   python3   div   使用   col   eve   ever   int   

 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

 

 

 

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

标签:log   body   python3   div   使用   col   eve   ever   int   

原文地址:https://www.cnblogs.com/jonm/p/8269872.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!