摘要: staticmethod/property/classmethod __new__:实例化时候执行,实例化,然后调用__init__执行 阅读全文
posted @ 2018-05-08 16:55 安慧桥没有你 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 把列表中的正数和负数分开排列. 把多维列表转为一维列表 查询列表中相同元素的个数 列表去重 阅读全文
posted @ 2018-03-14 22:04 安慧桥没有你 阅读(168) 评论(0) 推荐(0) 编辑
摘要: import subprocess# subprocess 是对os.system, os.spawn, os.popen的替换# sub_tmp1 = subprocess.call(['df', '-hT'], shell=False)# sub_tmp2 = subprocess.call([ 阅读全文
posted @ 2018-03-07 16:38 安慧桥没有你 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 正则表达式符号 a=re.match(pattern, string) a.groups()存储元组 阅读全文
posted @ 2018-03-07 14:13 安慧桥没有你 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 日志打印 日志级别,严重程度为:CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET 输出到多处 输出到文件 filename: 指定日志文件名filemode: 和file函数意义相同,指定日志文件的打开模式,'w'或'a'format: 指定输出的 阅读全文
posted @ 2018-03-06 17:55 安慧桥没有你 阅读(108) 评论(0) 推荐(0) 编辑
摘要: import hashlib # 主要提供SHA1, SHA224, SHA256, SHA384, SHA512, MD5 tmp = hashlib.md5() tmp.update(b'hello') print(tmp.hexdigest()) tmp.update('ddd的ddd'.encode(encoding='utf-8')) print(tmp.hexdigest()) i... 阅读全文
posted @ 2018-03-06 16:42 安慧桥没有你 阅读(88) 评论(0) 推荐(0) 编辑
摘要: import configparser # ConfigParser模块 # 生成一个configparser config = configparser.ConfigParser() config.add_section('666') config.set('666', 'hnm1', '1') config.set('666', 'hnm2', '2') with open('aoao.cn... 阅读全文
posted @ 2018-03-06 14:29 安慧桥没有你 阅读(100) 评论(0) 推荐(0) 编辑
摘要: import xml.etree.ElementTree as ET # xml通过节点来区别内容 tree = ET.parse("testxml.xml") root = tree.getroot() # print(root) # xml文档在内存中的位置 # print(root.tag) # 根标签名 # 遍历xml文档 for child ... 阅读全文
posted @ 2018-03-05 21:31 安慧桥没有你 阅读(140) 评论(0) 推荐(0) 编辑
摘要: import shelve # 是一个简单的k,v将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式 # 1, 把数据存入文件 d = shelve.open('hiniimx_test.txt') list1 = [1, 2, 3, 4] d['t2'] = list1 dict1 = {'hnm': 123, 'sophie': 456, 'annie... 阅读全文
posted @ 2018-03-05 18:06 安慧桥没有你 阅读(137) 评论(0) 推荐(0) 编辑
摘要: copy copy.copy(argu):浅copy,只在表层复制一个副本 copy.deepcopy(argu):深copy,完全复制一个副本 阅读全文
posted @ 2018-03-05 16:35 安慧桥没有你 阅读(120) 评论(0) 推荐(0) 编辑