摘要:
import hashlib # md5加密 obj = hashlib.md5() obj.update('123456'.encode('utf-8')) ret = obj.hexdigest() print(ret) # e10adc3949ba59abbe56e057f20f883e # 加盐版本 obj = hashlib.md5('admin'.encode('utf-8')) ob 阅读全文
摘要:
import configparser # 创建配置文件 config = configparser.ConfigParser() # config={} # config["DEFAULT"] = {'ServerAliveInterval': '45', 'Compression': 'yes', 'Co... 阅读全文
摘要:
import logging # 在文件和窗口二选一个位置打印信息,有filename的话在写入文件 logging.basicConfig( level=logging.DEBUG, # 设置错误级别 filename='logging.txt', # 日志文件名 filemode='w', # 文件打开模式 format='%(asctime)s %(filename)s [%(lineno) 阅读全文
摘要:
import re # findall('正则表达式',‘待匹配的字符串’) #返回匹配到字符串,并存放在列表中 text = 'abcdefg' res = re.findall('a..d', text) print(res) # ['abcd'] # 函数会在字符串内按规则匹配,当找到第一个匹配结果时就结束查找,然后返回一个包含匹配信息的对象,该对象可以 通过 调用group()方法 得到匹 阅读全文