上一页 1 ··· 3 4 5 6 7 8 下一页
摘要: re 模块 \w 字母数字下划线 \s 所有不可见字符 \d 所有数字 . 所有字符(除了换行符) \b 单词末尾 ^ 行首 $ 行尾 + 1个或多个 * 0个或多个 {m,n} 最少m次,最多n次 {m} 必须是m 次不能多不能少 {,n} 最大n 次 [abc] a|b|c 范围匹配 () 分组 阅读全文
posted @ 2018-08-14 17:09 星牧 阅读(89) 评论(0) 推荐(0) 编辑
摘要: configparser 是什么? 配置文件解析模块 什么是配置文件? 用于提供程序运行所需要的一些信息的文件 后缀 ini cfg 有什么用? 方便用户修改 例如超时时间配置文件内容格式 只包括两种元素 section 分区 option 选项 一个文件可以有多个section 一个section 阅读全文
posted @ 2018-08-13 22:21 星牧 阅读(85) 评论(0) 推荐(0) 编辑
摘要: hashlib hash是什么? 是一种算法 用于将任意长度的数据,压缩映射到一段固定长度的字符 (提取特征) hash的特点: 1.输入数据不同,得到的hash值有可能相同 2.不能通过hash值来得到输入的值 3.如果算法相同,无论输入的数据长度是多少,得到的hash值长度相同 常用的MD5就是一种has... 阅读全文
posted @ 2018-08-13 22:12 星牧 阅读(103) 评论(0) 推荐(0) 编辑
摘要: import xml.etree.ElementTree as ettree = et.parse('a.xml')root = tree.getroot()print(root)#三种查找节点的方式#(1)查找节点的方式 root.iter('year')res = root.iter('year 阅读全文
posted @ 2018-08-13 21:04 星牧 阅读(83) 评论(0) 推荐(0) 编辑
摘要: import shelveinfo = {'age':18,'name':'wxx'}info1 = {'age':16,'name':'cxx'}d = shelve.open('db.shv')d['wxx'] = infod["cxx"] = info1d.close()d = shelve.open('db.shv',writeback=True) #改文件d['wxx']['a... 阅读全文
posted @ 2018-08-13 18:07 星牧 阅读(83) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8# 注意:# 在python2中,包下必须有一个__init__.py文件,而python3中即便是没有也不会报错# 首次导入包,发送三件事,# 1. 以包下的__init_.py文件为基准来产生一个名称空间# 2. 执行包下的__init_.py文件的代码,将执行过程中产 阅读全文
posted @ 2018-08-10 19:42 星牧 阅读(97) 评论(0) 推荐(0) 编辑
摘要: import logging# 1. 控制日志级别# 2. 控制日志格式# 3. 控制输出的目标为文件logging.basicConfig(filename='access.log', format='%(asctime)s - %(name)s - %(levelname)s -%(module 阅读全文
posted @ 2018-08-10 18:59 星牧 阅读(151) 评论(0) 推荐(0) 编辑
摘要: bin (执行文件夹) start.ty conf (变量) setting.ry core (核心逻辑) scr.py lib (自定义模块) common.py db (数据库) db.txt log (日志) trandful.log readme.txt 阅读全文
posted @ 2018-08-10 14:31 星牧 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 1 import json 3 dic={'name':'alvin','age':23,'sex':'male'} 4 print(type(dic))# 6 j=json.dumps(dic) 7 print(type(j))# 10 f=open('序列化对象','w') 11 f.write(j) #-------------------等价于jso... 阅读全文
posted @ 2018-08-10 14:19 星牧 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 1 import random 3 print(random.random())#(0,1) float 大于0且小于1之间的小数 5 print(random.randint(1,3)) #[1,3] 大于等于1且小于等于3之间的整数 7 print(random.randrange(1,3)) 阅读全文
posted @ 2018-08-10 14:07 星牧 阅读(106) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 下一页