随笔分类 -  python

上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 48 下一页
摘要:class Dog(object): __first_new = True __instance = None def __new__(cls): if cls.__first_new: cls.__instance = object.__new__(cls) ... 阅读全文
posted @ 2018-12-05 12:33 anobscureretreat 阅读(154) 评论(0) 推荐(0)
摘要:pip install simplejson 阅读全文
posted @ 2018-11-29 16:32 anobscureretreat 阅读(294) 评论(0) 推荐(0)
摘要:>>> import bisect >>> scores = [(100, 'perl'), (200, 'tcl'), (400, 'lua'), (500, 'python')] >>> bisect.insort(scores, (300, 'ruby')) >>> scores [(100, 'perl'), (200, 'tcl'), (300, 'ruby'), (400, ' 阅读全文
posted @ 2018-11-27 19:25 anobscureretreat 阅读(7729) 评论(0) 推荐(1)
摘要:import random INDEXBOX=7 #哈希表元素个数 MAXNUM=13 #数据个数 class Node: #声明链表结构 def __init__(self,val): self.val=val self.next=None global indextable indextable=[Node... 阅读全文
posted @ 2018-11-25 23:20 anobscureretreat 阅读(598) 评论(0) 推荐(0)
摘要:class Node: #堆栈链结节点的声明 def __init__(self): self.data=0 #堆栈数据的声明 self.next=None #堆栈中用来指向下一个节点 top=None def isEmpty(): global top if(top==None): return 1 e... 阅读全文
posted @ 2018-11-25 19:41 anobscureretreat 阅读(385) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2018-11-25 18:14 anobscureretreat 阅读(356) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2018-11-25 17:41 anobscureretreat 阅读(217) 评论(0) 推荐(0)
摘要:读空的json文件,python2和python3 的错误提示是不一样的 python2: python3: 解决: 针对python2 针对python3 阅读全文
posted @ 2018-11-24 12:47 anobscureretreat 阅读(1206) 评论(0) 推荐(0)
摘要:import yaml yaml_dict={"sss":"111","ddd":"222"} with open("a.yaml", "w") as f: yaml.safe_dump(yaml_dict,f,encoding='utf-8', allow_unicode=True) with open("a.yaml") as f: yaml_dict = yaml.l... 阅读全文
posted @ 2018-11-23 19:00 anobscureretreat 阅读(388) 评论(0) 推荐(0)
摘要:>>> 'spam eggs' # single quotes 'spam eggs' >>> 'doesn\'t' # use \' to escape the single quote... "doesn't" >>> "doesn't" # ...or use double quotes instead "doesn't" >>> '"Yes," 阅读全文
posted @ 2018-11-23 17:07 anobscureretreat 阅读(219) 评论(0) 推荐(0)
摘要:>>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] >>> letters ['a', 'b', 'c', 'd', 'e', 'f', 'g'] >>> # replace some values >>> letters[2:5] = ['C&# 阅读全文
posted @ 2018-11-23 16:54 anobscureretreat 阅读(6306) 评论(0) 推荐(0)
摘要:>>> a = ['a', 'b', 'c'] >>> n = [1, 2, 3] >>> x = [a, n] >>> x [['a', 'b', 'c'], [1, 2, 3]] >>> x[0] ['a', 'b', 'c'] >>> x[0][1] 'b' 阅读全文
posted @ 2018-11-23 16:50 anobscureretreat 阅读(204) 评论(0) 推荐(0)
摘要:第一个元素一定是最小的,如果每次只想拿到列表的最小值,不想整个列表排序,可以通过不断返回最小值的方法实现 阅读全文
posted @ 2018-11-23 16:29 anobscureretreat 阅读(150) 评论(0) 推荐(0)
摘要:import zipfile import os,shutil import openpyxl file_list_pos="" fileName="" zipfileName="" def un_zip(file_name): """unzip zip file""" zip_file = zipfile.ZipFile(file_name) if o... 阅读全文
posted @ 2018-11-23 16:06 anobscureretreat 阅读(1049) 评论(0) 推荐(0)
摘要:在当前路径解压zip压缩包,生成同名文件夹,内部目录结构与压缩包一致 阅读全文
posted @ 2018-11-23 16:04 anobscureretreat 阅读(5047) 评论(0) 推荐(0)
摘要:import zipfile file_name="a.txt" f = zipfile.ZipFile('test.zip','w',zipfile.ZIP_STORED) f.write(file_name) f.close() 阅读全文
posted @ 2018-11-23 15:47 anobscureretreat 阅读(2810) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2018-11-23 14:51 anobscureretreat 阅读(801) 评论(0) 推荐(0)
摘要:import glob x=glob.glob('*.py') print(x) 阅读全文
posted @ 2018-11-23 11:01 anobscureretreat 阅读(3736) 评论(0) 推荐(0)
摘要:import itertools original_list = [[2,4,3],[1,5,6], [9], [7,9,0]] new_merged_list = list(itertools.chain(*original_list)) print(new_merged_list) 阅读全文
posted @ 2018-11-22 21:29 anobscureretreat 阅读(2716) 评论(0) 推荐(0)
摘要:输出 阅读全文
posted @ 2018-11-22 20:32 anobscureretreat 阅读(217) 评论(0) 推荐(0)

上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 48 下一页