码迷,mamicode.com
首页 > 其他好文 > 详细

Split string every nth character?

时间:2017-09-28 18:04:42      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:get   overflow   ever   bsp   targe   pretty   https   question   int   

 

https://stackoverflow.com/questions/9475241/split-string-every-nth-character

 

>>> line = ‘1234567890‘
>>> n = 2
>>> [line[i:i+n] for i in range(0, len(line), n)]
[‘12‘, ‘34‘, ‘56‘, ‘78‘, ‘90‘]

 

Split string every nth character?

标签:get   overflow   ever   bsp   targe   pretty   https   question   int   

原文地址:http://www.cnblogs.com/antflow/p/7607567.html

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