摘要: hashlib模块 import hashlib# 基本使用cipher = hashlib.md5('需要加密的数据的二进制形式'.encode('utf-8'))print(cipher.hexdigest()) # 加密结果码 # 加盐cipher = hashlib.md5()cipher. 阅读全文
posted @ 2019-07-06 22:48 士大夫给力 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 什么是序列化? 我们把对象(变量)从内存中变成可存储或传输的过程称之为序列化,在Python中叫pickling,在其他语言中也被称之为serialization,marshalling,flattening等等,都是一个意思 为什么要序列化? 1:持久保存状态 需知一个软件/程序的执行就在处理一系 阅读全文
posted @ 2019-07-06 22:21 士大夫给力 阅读(105) 评论(0) 推荐(0) 编辑
摘要: shevle:可以用字典存取数据到文件的序列化模块 shevle只有一个open函数,返回类似字典的对象,可读可写;key必须为字符串,而值可以是python所支持的数据类型 # 将序列化文件操作dump与load进行封装s_dic = shelve.open("target_file", writ 阅读全文
posted @ 2019-07-05 22:17 士大夫给力 阅读(151) 评论(0) 推荐(0) 编辑
摘要: shutil模块:高级的 文件、文件夹、压缩包 处理模块 # 基于路径的文件复制:shutil.copyfile('source_file', 'target_file') # 基于流的文件复制:with open('source_file', 'rb') as r, open('target_fi 阅读全文
posted @ 2019-07-05 21:57 士大夫给力 阅读(125) 评论(0) 推荐(0) 编辑
摘要: random:随机数 阅读全文
posted @ 2019-07-05 21:20 士大夫给力 阅读(130) 评论(0) 推荐(0) 编辑
摘要: os:操作系统 在os中提供很多关于文件 , 文件夹 ,路径处理的函数 import os os.path:系统路径操作 import os.path 阅读全文
posted @ 2019-07-05 21:08 士大夫给力 阅读(137) 评论(0) 推荐(0) 编辑
摘要: sys 与解释器相关的一些操作system 代表的不是操作系统而是解释器自己 import sys 阅读全文
posted @ 2019-07-05 21:00 士大夫给力 阅读(116) 评论(0) 推荐(0) 编辑
摘要: time:时间 import time 时间戳(timestamp):time.time()延迟线程的运行:time.sleep(secs)(指定时间戳下的)当前时区时间:time.localtime([secs])(指定时间戳下的)格林威治时间:time.gmtime([secs])(指定时间元组 阅读全文
posted @ 2019-07-05 20:50 士大夫给力 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 什么是logging模块 logging模块是python提供的用于记录日志的模块 为什么需要logging 我们完全可以自己打开文件然后,日志写进去,但是这些操作重复且没有任何技术含量,所以python帮我们进行了封装,有了logging后我们在记录日志时 只需要简单的调用接口即可,非常方便! 日 阅读全文
posted @ 2019-07-04 23:33 士大夫给力 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 三目运算符 推导式 递归 # count = 0# 自己调自己# def a():# global count# count += 1# if count > 50:# return# a()# a() # 函数间接调用自己:一旦形成循环调用,就产生了递归def b(): c()def c(): d 阅读全文
posted @ 2019-07-04 23:26 士大夫给力 阅读(1066) 评论(0) 推荐(0) 编辑