zoukankan      html  css  js  c++  java
  • configparse模块和hashlib模块

    # import configparser
    #
    # config = configparser.ConfigParser()  #config = {}
    
    # config['DEFAULT'] = {'ServerAliveInterval':'45',
    #                      'Compression':'yes',
    #                      'CompressionLevel':'9'}
    #
    # config['bitbucket.org'] = {}
    # config['bitbucket.org']['User'] = 'hg'
    #
    # config['topsecret.server.com'] = {}
    # topsecret = config['topsecret.server.com']
    # topsecret['Host Port'] = '50022'
    # topsecret['ForwardX11'] = 'no'
    # config['DEFAULT']['ForwardX11'] = 'yes'
    #
    #
    # with open('example.ini','w') as f:
    #     config.write(f)
    
    
    
    
    import configparser
    
    config = configparser.ConfigParser()  #config = {}
    config.read('example.ini')
    
    # 查
    # print(config.sections())
    # print('bytehong.com' in config)
    # print(config['bitbucket.org']['User'])
    # print(config['DEFAULT']['Compression'])
    # print(config['topsecret.server.com']['ForwardX11'])
    
    # for key in config['bitbucket.org']:
    #     print(key)
    
    
    # print(config.options('bitbucket.org'))
    # print(config.items('bitbucket.org'))
    # print(config.get('bitbucket.org','compression'))
    
    
    
    # 增
    # config.add_section('hello')
    # config.set('hello','k1','123')
    
    # 删
    # config.remove_section('topsecret.server.com')
    # config.remove_option('bitbucket.org','User')
    
    config.write(open('test.txt','w'))
    

      

    # 用于加密相关的操作,主要提sha1,sha224,sha384,sha512,md5算法
    # 算法越复杂,消耗的时间越多
    import hashlib
    
    # obj = hashlib.md5('sb'.encode('utf-8'))
    
    obj = hashlib.md5()
    
    # obj.update("hello".encode('utf-8'))
    # print(obj.hexdigest())
    
    # obj.update('helloroot'.encode('utf-8'))
    # print(obj.hexdigest())
    

      

  • 相关阅读:
    匿名对象
    再次安装xampp遇到的各类问题汇总
    jupyter notebook添加Anaconda虚拟环境的python kernel
    1003. 我要通过!
    大数据分析-excel常用技巧
    Jupyter Notebook 修改默认打开的文件夹的位置
    A*算法介绍
    MATLAB常用函数(不定时更新)
    2019数学建模美赛感悟
    Windows许可证即将到期激活教程
  • 原文地址:https://www.cnblogs.com/geeker-xjl/p/8900765.html
Copyright © 2011-2022 走看看