zoukankan      html  css  js  c++  java
  • 常用模块3

    # hashlib模块

    # 1、什么叫hash:hash是一种算法,该算法接受传入的内容,经过运算得到一串hash值
    # 2、hash值的特点是:
    #2.1 只要传入的内容一样,得到的hash值必然一样=====>要用明文传输密码文件完整性校验
    #2.2 不能由hash值返解成内容=======》把密码做成hash值,不应该在网络传输明文密码
    #2.3 只要使用的hash算法不变,无论校验的内容有多大,得到的hash值长度是固定的
    # import hashlib
    # m=hashlib.md5()
    # m.update('hello word '.encode('utf-8'))
    # print(m.hexdigest()) #e5ab6c6313657418d6a58f0e369d1e1d

    # 文件生成hash值
    # import hashlib
    # m=hashlib.md5()
    # with open(r'D:python练习day.18dos.py','rb')as f:
    # for line in f:
    # m.update(line)
    # hv=m.hexdigest()
    # print(hv)
    # hash值
    #17133f25421d160b1d8386e1ced19b14
    # 09f1651800a15fa2ecde2ab3cba357d4
    # 5d8bbdcde98b5454678afd55c774f965
    # 5e921783ca2111d70eb810d64e9f9495
    # 071cb6a398992f6ea18751d06bffb4b0
    # 2f99326787fac41196cbe6c262986e59
    # 11b3b5fcf50c077c1aabc616abbb5759
    # ecda66e62aaee8095da6da7f93a561aa
    # df74acf08aa3255cf467ed9777564952
    # 398c3e50311756403a1855a089840cc5
    # 55576b5b403db77484e5df188c3022f2
    # 34b0178aa75ad890970e2b5387a1ff97
    # 2b9f58825663c1fcd3964a6266e01351
    # eaefcee5737461ee4a5aadd51e8ec9df
    # f906c4ea15b81e07b77504e1b5db4921
    # 21cd49cf3182d24e65df4207d6b557b2
    # e6bee699b0597dd59271e29f3a4e946f
    # 密码加盐:
    # import hashlib
    # pwd='alex3714'
    #
    # m=hashlib.md5()
    # m.update('天王盖地虎'.encode('utf-8'))
    # m.update(pwd.encode('utf-8'))
    # m.update('提莫一米五'.encode('utf-8'))
    # print(m.hexdigest())


    # subprocess模块

    # import os
    #
    # res=os.system('dixCVr')
    # print('运行结果:',res)

    # import subprocess
    #
    # obj=subprocess.Popen('dir',
    # shell=True,
    # stdout=subprocess.PIPE,
    # stderr=subprocess.PIPE
    # )

    # print(obj)

    # res1=obj.stdout.read()
    # print('正确结果1111: ',res1)
    #
    # res2=obj.stdout.read()
    # print('正确结果2222: ',res2) #只能取一次,取走了就没有了
    #

    # configparser模块


    # mport configparser
    #
    # config=configparser.ConfigParser()
    # config.read('my.ini')
    #
    # # secs=config.sections()
    # # print(secs)
    #
    # # print(config.options('egon'))
    #
    # # age=config.get('egon','age')`
    # # age=config.getint('egon','age')
    # # print(age,type(age))
    #
    # # salary=config.getfloat('egon','salary')
    # # print(salary,type(salary))
    #
    # b=config.getboolean('egon','is_beatifull')
    # print(b,type(b))
  • 相关阅读:
    BZOJ1527 : [POI2005]Pun-point
    2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)
    2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)
    NAIPC-2016
    BZOJ2498 : Xavier is Learning to Count
    ACM ICPC Vietnam National Second Round
    XVI Open Cup named after E.V. Pankratiev. GP of Ukraine
    XVI Open Cup named after E.V. Pankratiev. GP of Peterhof
    HDU5509 : Pattern String
    BZOJ4583 : 购物
  • 原文地址:https://www.cnblogs.com/yangwei666/p/8778989.html
Copyright © 2011-2022 走看看