Python基础-configparser和hashlib模块
2024-08-29 13:23:21
configparser模块
import configparser
config = configparser.ConfigParser()
#将配置写入到文件
config['DEFAULT'] = {'ServerAliveInterval': '',
'Compression': 'yes',
'CompressionLevel': ''}
config['bitbucket.org'] = {'User': 'fansik'}
config['www.fansik.com'] = {'Host Port': '',
'ForwardX11': 'no'}
config['DEFAULT']['ForwardX11'] = 'yes' with open('example.ini', 'w') as configfile:
config.write(configfile) # 读取配置
config.read('example.ini', encoding='utf8')
print(config.sections())
print(config.defaults())
for key in config['bitbucket.org']: # 这个key包含DEFAULT中的内容
print(key) # 修改配置
config.remove_section('bitbucket.org')
config.has_section('bitbucket.org') # 判断是否删除成功
config.write(open('example.ini', 'w'))
# 修改单个的配置
config.set('www.fansik.com', 'forwardx11', 'yes')
# 删除单个配置
config.remove_option('www.fansik.com', 'forwardx11')
hashlib加密模块
import hashlib
password = hashlib.md5()
password.update('fanjinbao'.encode('utf8'))
print(password)
print(password.hexdigest())
password.update('fansik'.encode('utf8'))
print(password.hexdigest()) password2 = hashlib.sha256()
password2.update('fanjinbao'.encode('utf8'))
print(password2.hexdigest()) password3 = hashlib.sha256()
password3.update('fanjinbao'.encode('utf8'))
print(password2.hexdigest())
最新文章
- android 中layer-list的用法
- RCP:如何移除Search对话框中不需要的项
- Activity 和 生命周期: 创建
- Java基础(39):数据的四舍五入、去整、产生随机数---Math类的应用
- c++ encode decode
- tools/adb: No such file or directory
- 虚拟桌面基础架构(VDI)与终端服务和传统PC对比
- [转载]如何打一手好Log
- C#/PHP Compatible Encryption (AES256) ZZ
- Register/unregister a dll to GAC
- v4l2视频采集摄像头
- Linux(CentOS6.7) 安装MySql5.7数据库
- spring框架整合hibernate框架简单操作数据库
- failed to find global analyzer [uax_url_email]
- [leetcode]61. Rotate List旋转链表
- socketv 验证客户端链接的合法性,socketserver
- ArrayList、LinkList、Vector的区别
- react+dva+antd项目构建
- 085 HBase的二级索引,以及phoenix的安装(需再做一次)
- oracle锁---原理篇
热门文章
- linux命令ulimit 系统限制你打开一些资源数
- opengl剪裁空间和视口空间中不遵从右手定则,而是遵从左手定则
- Spring mvc 注解@ResponseBody 返回内容编码问题
- Flex colorTranfrom使用说明
- UML类图详解_泛化关系
- 百度UEditor 用require 引入 Thinkphp5 ,图片上传问题
- scp -P 非22端口拷贝
- SecureCRTPortable.exe 如何上传文件
- Spring MVC静态页面
- 用VS2010进行CMAKE的时候“LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏”