python
loujingxian
这个作者很懒,什么都没留下…
展开
-
python 每次取数组一部分,并再原数组删除此部分
input_files = [] for num in range(1, 347): file_info = {'num': num} input_files.append(file_info) index = 0 bulk_num = 25 while len(input_files) >= bulk_num: child_list = input_files[0:bulk_num:1] ...原创 2020-11-04 16:34:56 · 1273 阅读 · 0 评论 -
python 按普通字典排序(小写字母,排在大写字母前)
str.sort(key=str.lower)spam = ['a','z','A','C']spam.sort()print(spam)spam.sort(key=str.lower)print(spam)原创 2017-03-19 18:47:10 · 10828 阅读 · 1 评论 -
python 字典 按key值大小 倒序取值
viedoUrl_dict = {1:'hello',2:'python',3:'nihao'}bit_list = sorted(viedoUrl_dict.keys())bit_list.reverse()for key in bit_list: m3u8_url = viedoUrl_dict[key] print(m3u8_url)原创 2017-03-12 11:47:27 · 5712 阅读 · 0 评论 -
Python中使用logging模块代替print
此文转载自http://www.jb51.net/article/52022.htm替换print?print怎么了?print 可能是所有学习Python语言的人第一个接触的东西。它最主要的功能就是往控制台 打印一段信息,像这样:复制代码代码如下:print 'Hello, logging!'print也是绝大多数人用来转载 2017-03-15 17:48:40 · 1629 阅读 · 1 评论 -
python list存放对象,按对象某个属性排序
如果list中放的 one_video 对象,需要按 对象的show_date属性 倒序排列,则写法如下: channel_list.sort(key=lambda one_video: one_video.show_date,reverse=True)原创 2017-11-04 10:53:27 · 9646 阅读 · 0 评论