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模块的更多相关文章

  1. Python 入门之 内置模块 -- hashlib模块

    Python 入门之 内置模块 -- hashlib模块 1.hashlib 摘要算法,加密算法 (1)主要用途: <1> 加密 : md5 sha1 sha256 sha512 md5, ...

  2. python 闭包,装饰器,random,os,sys,shutil,shelve,ConfigParser,hashlib模块

    闭包 def make_arerage(): l1 = [] def average(price): l1.append(price) total = sum(l1) return total/len ...

  3. python基础(10)--模块

    模块(module) 模块,用一坨代码实现了某个功能的代码集合 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来 ...

  4. 024--python re、logging、configparser、hashlib模块

    一.re模块 re模块又称正则表达式是一种小型的.高度专业化的编程语言,(在Python中)它内嵌在Python中,并通过 re 模块实现.正则表达式模式被编译成一系列的字节码,然后由用 C 编写的匹 ...

  5. Python基础(十)-模块

    模块初识 一般把不同功能代码放到不同py文件,一个py文件就是一个模块 三种模块库: 1.Python标准库 2.第三方库 3.自定义库 导入模块:import 库名 (Python解释器只认识执行文 ...

  6. 第六章:Python基础の反射与常用模块解密

    本课主题 反射 Mapping 介绍和操作实战 模块介绍和操作实战 random 模块 time 和 datetime 模块 logging 模块 sys 模块 os 模块 hashlib 模块 re ...

  7. md5模块(Python内置模块)和hashlib模块

    转自https://my.oschina.net/duhaizhang/blog/67214 MD5模块用于产生消息摘要,康用来判断文件是否相同. python的md5模块使用非常简单,包括以下几个函 ...

  8. pickle\json,configparser,hashlib模块

    python常用模块 目录 python常用模块 json模块\pickle模块 configparser模块 hashlib模块 subprocess模块 json模块\pickle模块 首先说一下 ...

  9. 小白的Python之路 day5 hashlib模块

    hashlib模块 一.概述 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法 二.算法的演 ...

随机推荐

  1. angular4 开发记录

    1,传值问题 page setValue:  [routerLink]="['/product-details', product.id]"> ts     seValue: ...

  2. leetCode 30.Substring with Concatenation of All Words (words中全部子串相连) 解题思路和方法

    Substring with Concatenation of All Words You are given a string, s, and a list of words, words, tha ...

  3. iptables修改

    https://fedoraproject.org/wiki/How_to_edit_iptables_rules?rd=User_talk:Rforlot Listing Rules Current ...

  4. crontab用法

    在工作中有时需要定时执行某些操作,于是想到使用crontab来实现 crontab的用法: crontab file [-u user]    用指定的文件替代目前的crontab crontab - ...

  5. UI-2-UILabel&UIImageView-补充

    课程要点: 控件之间的继承关系. UILabel UIImageView 利用UIImageView实现帧动画 补充 试图之间的继承关系 昨天学习UIView的时候,了解到UIView里面有以下几个常 ...

  6. SVN常见问题(转)

    svn常见问题,报错,命令及我的总结 (2013-07-19 18:07:27) 转载▼     我自己犯过的一个错误是:/svn/MyERP_core_Main/!svn/act/b8bd621b- ...

  7. archive的时候报“ no identity found&quot;错误 解决方式

    第一步: 在xcode----target----general----identity----team里 增加你们公司的账号就能够了 第二步: Xcode > Preferences > ...

  8. 配置LANMP环境(3)-- 安装anmp前准备与实用软件安装

    一.安装配置vim 1.安装 yum -y install vim* 2.创建文件夹 mkdir -p /etc/vim/ 3.配置 vim ~/.vimrc  "插入模式时 光标的上下左右 ...

  9. 深入理解:单一入口、MVC、ORM、CURD、ActiveRecord概念

    本篇文章是对单一入口.MVC.ORM.CURD.ActiveRecord概念进行了详细的分析介绍,需要的朋友参考下     MVC MVC是一个设计模式,它强制性的使应用程序的输入.处理和输出分开.使 ...

  10. important——》sql server 2000安装图解

    MS Sql Server 2000包含两个部分:服务器组件和客户端工具,其中服务器组建是以Windows服务的方式运行的,有四种服务分别是:MSSqlServer.Distributed Trans ...