Python9-模块1-day19】的更多相关文章

上周五回顾 logging 用于记录日志 四种核心角色: 生成器Logger 过滤器Filter 处理器Handler 格式化处理器 Formatter logging.info.debug 使用默认配置 配置方式: 1.basicConfig 2.自己创建四种角色 并进行关联 3.用配置文件,字典来配置 logging.config 配置完后 用logging.config.dictConfig(loggin_config.LOGGING_DIC) aaloger = loger.GetLog…
day19 python   一.序列化模块     序列类型: 列表 字符串 元组 bytes     序列化: 特指字符串和bytes, 就是把其他的数据类型转化成序列的数据类型的过程 dic = {'1','2'} print(str(dic))     #这就是序列化     1.为什么要把其他数据类型转成字符串: 一.能在网络上传输的只能是bytes, 能存在文件里的只有bytes和str(本质都是bytes)                                     …
os模块:对系统进行操作(6+3) system  popen  listdir  getcwd  chdir  environ / name  sep  linesep import os #### os模块方法 #### # 1.system 在python中执行系统命令 os.system("ifconfig") os.system("touch 1.txt") # 2.popen 执行系统命令返回对象 # 可以通过read方法读出字符串,防止字符串乱码,使用…
一.hashlib模块:加密1.基本使用:import hashlibcipher = hashlib.md5('需要加密的数据(二进制形式)'.encode('utf-8'))print(cipher.hexdigest()) #加密结果码2.加盐cipher = hashlib.md5()cipher.update('前盐'.encode('utf-8'))cipher.update('需要加密的数据'.encode('utf-8'))cipher.update('后盐'.encode('u…
collections模块 详细内容 http://www.cnblogs.com/Eva-J/articles/7291842.html 1.namedtuple: 生成可以使用名字来访问元素内容的tuple from collections import namedtuple Point = namedtuple('changfx',['x','y','z']) # 变量 = namedtuple('名字',[元祖元素]) 这里以一个长方形为例子 p = Point(5,6,7) print…
http://www.cnblogs.com/Eva-J/articles/7228075.html#_label10 collections模块: 在内置数据类型(dict.list.set.tuple)的基础上,collections模块还提供了几个额外的数据类型:Counter.deque.defaultdict.namedtuple和OrderedDict等. 1.namedtuple:生成可以使用名字来访问元素内容的tuple. #namedtuple('名称', [属性list]):…
http://www.cnblogs.com/Eva-J/articles/7228075.html  所有常用模块的用法 正则的规则: 在一个字符组里面枚举合法的所有字符,字符组里面的任意一个字符和‘带匹配字符’都相同,都视为可以匹配. #是数字 #11位 #以13|15|17|18|16|14 # num = input('phone_number : ') # if num.isdigit() and len(num) == 11 and num.startswith('13') or \…
1,正则复习,re.S,这个在用的最多,re.M多行模式,这个主要改变^和$的行为,每一行都是新串开头,每个回车都是结尾.re.L 在Windows和linux里面对一些特殊字符有不一样的识别,re.L 是根据当前的操作系统来识别,这个不推荐使用,他就不一样了.正常还是走我们的记得意思,re.U 这个对于ASCII码是一样的,对于中文才使用Unicode,re.X和re.M有点像 import re ret = re.findall('.*\d+','hsd739y8kk \ns99sihf99…
常用模块21 shelve模块  也是一种序列化方式    使用方法        1.open     sl = shelve.open("shelvetest.txt")   读出来s1是一个字典形式,注意关闭文件         2.读写    写进去 sl["date"] = "8-13"    读出来   s2.get("list1")        3.close   注意关闭文件      特点:使用方法比较简单…
1.sys模块 import sys sys.path()#打印系统path sys.version()#解释程序版本信息 sys.platform()#系统平台 sys.exit(0)#退出程序 command=sys.argv[1]#从程序外部获取参数 sys.stdout.write('#')#与print相同,区别是刷进缓存 # 例子 import time for i in range(10): sys.stdout.write('#') time.sleep(1) sys.stdou…