• 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())
    

      

  • 相关阅读:
    [LeetCode] 1898. Maximum Number of Removable Characters
    [LeetCode] 1897. Redistribute Characters to Make All Strings Equal
    [LeetCode] 1400. Construct K Palindrome Strings
    235. 二叉搜索树的最近公共祖先
    349. 两个数组的交集
    海量数据TOPK 问题
    121. 买卖股票的最佳时机
    删除数组中为0元素
    这行字符串中出现频率最高的字符
    50. Pow(x, n)
  • 原文地址:https://www.cnblogs.com/geeker-xjl/p/8900765.html
Copyright © 2020-2023  润新知