Python基础-configparser和hashlib模块
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())
Python基础-configparser和hashlib模块的更多相关文章
- Python 入门之 内置模块 -- hashlib模块
Python 入门之 内置模块 -- hashlib模块 1.hashlib 摘要算法,加密算法 (1)主要用途: <1> 加密 : md5 sha1 sha256 sha512 md5, ...
- python 闭包,装饰器,random,os,sys,shutil,shelve,ConfigParser,hashlib模块
闭包 def make_arerage(): l1 = [] def average(price): l1.append(price) total = sum(l1) return total/len ...
- python基础(10)--模块
模块(module) 模块,用一坨代码实现了某个功能的代码集合 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来 ...
- 024--python re、logging、configparser、hashlib模块
一.re模块 re模块又称正则表达式是一种小型的.高度专业化的编程语言,(在Python中)它内嵌在Python中,并通过 re 模块实现.正则表达式模式被编译成一系列的字节码,然后由用 C 编写的匹 ...
- Python基础(十)-模块
模块初识 一般把不同功能代码放到不同py文件,一个py文件就是一个模块 三种模块库: 1.Python标准库 2.第三方库 3.自定义库 导入模块:import 库名 (Python解释器只认识执行文 ...
- 第六章:Python基础の反射与常用模块解密
本课主题 反射 Mapping 介绍和操作实战 模块介绍和操作实战 random 模块 time 和 datetime 模块 logging 模块 sys 模块 os 模块 hashlib 模块 re ...
- md5模块(Python内置模块)和hashlib模块
转自https://my.oschina.net/duhaizhang/blog/67214 MD5模块用于产生消息摘要,康用来判断文件是否相同. python的md5模块使用非常简单,包括以下几个函 ...
- pickle\json,configparser,hashlib模块
python常用模块 目录 python常用模块 json模块\pickle模块 configparser模块 hashlib模块 subprocess模块 json模块\pickle模块 首先说一下 ...
- 小白的Python之路 day5 hashlib模块
hashlib模块 一.概述 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法 二.算法的演 ...
随机推荐
- Java实现XSS防御
XSS概述 跨站脚本攻击(Cross Site Scripting),缩写为XSS.恶意攻击者往Web页面里插入恶意Script代码,当用户浏览该页之时,嵌入其中Web里面的Script代码会被执行, ...
- Codeforces Round #244 (Div. 2)——Checkposts
题目链接 题意: 给定n个点,每一个点有一个权值的有向图.如今须要选定一些点,使得这些点权值和最小.且满足:假设i能到达j且j能到达i,那么i.j能够仅仅选一个 分析: 强联通模板题 //使用时仅仅更 ...
- 代码转换工具 Java to C#
http://www.tangiblesoftwaresolutions.com/ (Java 2 C#) http://www.tangiblesoftwaresolutions.com/Produ ...
- 如何在Linux下统计高速网络中的流量
参考: http://www.geekfan.net/5558/ http://blog.jobbole.com/23638/ http://www.csdn.net/article/2014-03- ...
- c++ using Handle Class Pattern to accomplish implementation hiding
Reference material: Thinking In C++ 2nd eidition chapter 5 section "Handle classes" If the ...
- “Missing artifact....."的解决办法
在使用Maven开发时,总会碰到一些问题,例如"Missing artifact org.apache.commons:commons-csv:jar:1.0-SNAPSHOT", ...
- MII接口概念简述
MII: Medium Independent Interface 媒体独立接口,也称介质无关接口 RMII: Reduced MII 简化媒体独立接口 GMII: Gigabit Medium In ...
- 挑战:万能的slash! 判断js中“/”是正则、除号、注释?
很久以前在其它地方就探讨和关注过这个问题,但都没有满意的解答. 看了zjfeihu 的帖子: <前端代码加亮插件(html,jss,css),支持即时加亮,运行代码>,再次提出这个比较经典 ...
- Android 缓存详解目录
1.http://www.cnblogs.com/lzrabbit/p/3734850.html 2.
- echarts Y轴刻度保留几位小数
yAxis: [ { type: 'value', name: '雨量(mm)', nameLocation: 'start', inverse: true, axisLabel: { ...