python: heap Tree, hash Table
# encoding: utf-8 # 版權所有 2024 ©塗聚文有限公司 # 許可資訊查看:言語成了邀功的功臣,還需要行爲每日來值班嗎? # 描述: 主、子表單 窗體傳值 Parent-child form operations # Author : geovindu,Geovin Du 塗聚文. # IDE : PyCharm 2023.1 python 3.11 # OS : windows 10 # Datetime : 2024/10/24 20:09 # User : geovindu # Product : PyCharm # Project : IctGame # File : ui/main.py # explain : 學習 import heapq # https://docs.python.org/3/library/heapq.html import hashlib h = [10, 21, 5, 12, 88, 3, 100, 111, 200] heapq.heapify(h) # 取出了最小的 print(h) val = heapq.heappop(h) print(h) print('最小三个:', heapq.nlargest(3, h)) print('最大三个:', heapq.nsmallest(3, h)) print(h) def checkname(name: str): if voted[name]: print('你已投过票了') else: print('欢迎你投票') voted[name] = True voted = {'Jason': None, 'Lisa': None, 'Mike': None} while True: name = input("请输入姓名:") if name in voted: checkname(name) else: print('你不是投票者') yn = input("y/n?") if yn == 'y' or yn == 'Y': pass else: break data = hashlib.md5() #sha1() data.update(b'geovindu') print('hash value=',data.digest()) print('hassh value(16 byte)',data.hexdigest()) print(type(data)) print(type(data.hexdigest())) school='涂聚文大学' data.update(school.encode('utf-8')) print('hash value=',data.digest()) print('hassh value(16 byte)',data.hexdigest()) print(type(data)) print(type(data.hexdigest())) print(hashlib.algorithms_available) #平台的杂凑算法 {'sha512', 'shake_128', 'whirlpool', 'sha3_256', 'sha256', 'sha1', 'sha512_224', 'mdc2', 'md5-sha1', 'sha3_224', 'sha3_384', 'shake_256', 'blake2s', 'md5', 'sha224', 'sm3', 'blake2b', 'md4', 'sha384', 'sha3_512', 'sha512_256', 'ripemd160'} filename='1.txt' with open(filename,mode='rb') as fn: btxt=fn.read() data.update(btxt) print('hash value=',data.digest()) print('hassh value(16 byte)',data.hexdigest()) print(type(data)) print(type(data.hexdigest()))
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)