python将list连续元素和非连续元素分开转换为指定字符串,pythonlist,obj = {}def
python将list连续元素和非连续元素分开转换为指定字符串,pythonlist,obj = {}def
obj = {}def test(nums): nums.append(0) for item in nums: start = obj.get('start', item) end = obj.get('end', item) if item - end != 1: yield "%s"%start if start == end else '%s~%s'%(start, end) obj['start'] = item obj['end'] = itemlst = [1, 2, 3, 4, 5, 7, 8, 15, 20, 21, 22, 23, 24, 28]print ','.join([x for x in test(lst)][1:])
相关内容
- python自动裁剪图像,python裁剪图像,本代码可以帮你自动
- 链接整理器 主要是做灰帽SEO使用的 使用PYQT开发,整理
- 用python从多个文件中提取有用信息到一个文件中,pyt
- python截取文件指定行进行合并.py,python.py,"""pytho
- python对比语言文件输出等号前面不同的行.py,python.py
- 使用python进行密码暴力破解,python密码暴力破解,根据字
- python多线程不断刷新网页的代码,python多线程刷新,这段
- python旋转图片的代码,,# rotate an
- 检查网站可用性的Python代码,可用性python代码,#!/usr/b
- python封装的GET&POST请求,python封装GET, #codi
评论关闭