如何将unicode转换为4位二进制表示?

2024-10-03 02:43:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下功能:

def dict_to_binary(the_dict):
    json_dict = json.dumps(the_dict)
    binary = ' '.join(format(ord(letter), 'b') for letter in json_dict)
    return binary

def binary_to_dict(the_binary):
    jsn = ''.join(chr(int(x, 2)) for x in the_binary.split())
    d = json.loads(jsn)  
    return d

这些函数接收dict对象,将其转换为json,然后使用ord获取json中每个项的unicode,然后将其转换为二进制。你知道吗

我如何编辑format字符串来实现4位二进制表示,而不是它当前表示的8位二进制表示?完整代码如下:

inverted_index = {word:(document_frequency[word], d[word]) for word in d}

thebinary = dict_to_binary(inverted_index)
print(thebinary)
print()
print()
print()
convertedbinary = binary_to_dict(thebinary)
print(convertedbinary)

收益率

1111011 100010 1101100 1101111 1110010 1100101 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110001 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101001 1110000 1110011 1110101 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110001 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100100 1101111 1101100 1101111 1110010 100010 111010 100000 1011011 110010 101100 100000 1011011 1011011 110001 101100 100000 110001 1011101 101100 100000 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110011 1101001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110001 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100001 1101101 1100101 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110001 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100011 1101111 1101110 1110011 1100101 1100011 1110100 1100101 1110100 1110101 1110010 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100001 1100100 1101001 1110000 1101001 1110011 1100011 1101001 1101110 1100111 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1101100 1101001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110011 1100101 1100100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1101001 1110101 1110011 1101101 1101111 1100100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110100 1100101 1101101 1110000 1101111 1110010 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101001 1101110 1100011 1101001 1100100 1101001 1100100 1110101 1101110 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110101 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110011 1011101 101100 100000 1011011 110010 101100 100000 110011 1011101 101100 100000 1011011 110010 101100 100000 110011 1011101 1011101 1011101 101100 100000 100010 1101100 1100001 1100010 1101111 1110010 1100101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100100 1101111 1101100 1101111 1110010 1100101 100010 111010 100000 1011011 110010 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 101100 100000 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101101 1100001 1100111 1101110 1100001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100001 1101100 1101001 1110001 1110101 1100001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1101110 1101001 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100001 1100100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101101 1101001 1101110 1101001 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110110 1100101 1101110 1101001 1100001 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110001 1110101 1101001 1110011 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101110 1101111 1110011 1110100 1110010 1110101 1100100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1111000 1100101 1110010 1100011 1101001 1110100 1100001 1110100 1101001 1101111 1101110 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110101 1101100 1101100 1100001 1101101 1100011 1101111 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101100 1100001 1100010 1101111 1110010 1101001 1110011 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101110 1101001 1110011 1101001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100001 1101100 1101001 1110001 1110101 1101001 1110000 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1111000 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1100001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100011 1101111 1101101 1101101 1101111 1100100 1101111 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100011 1101111 1101110 1110011 1100101 1110001 1110101 1100001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110010 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100100 1110101 1101001 1110011 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100001 1110101 1110100 1100101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101001 1110010 1110101 1110010 1100101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110010 1100101 1110000 1110010 1100101 1101000 1100101 1101110 1100100 1100101 1110010 1101001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110110 1101111 1101100 1110101 1110000 1110100 1100001 1110100 1100101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110110 1100101 1101100 1101001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1110011 1110011 1100101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100011 1101001 1101100 1101100 1110101 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1110101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100110 1110101 1100111 1101001 1100001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101110 1110101 1101100 1101100 1100001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110000 1100001 1110010 1101001 1100001 1110100 1110101 1110010 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110011 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1111000 1100011 1100101 1110000 1110100 1100101 1110101 1110010 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110011 1101001 1101110 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101111 1100011 1100011 1100001 1100101 1100011 1100001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100011 1110101 1110000 1101001 1100100 1100001 1110100 1100001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101110 1101111 1101110 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110000 1110010 1101111 1101001 1100100 1100101 1101110 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110011 1110101 1101110 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100011 1110101 1101100 1110000 1100001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1110001 1110101 1101001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101111 1100110 1100110 1101001 1100011 1101001 1100001 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100100 1100101 1110011 1100101 1110010 1110101 1101110 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101101 1101111 1101100 1101100 1101001 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100001 1101110 1101001 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101001 1100100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1100101 1110011 1110100 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 101100 100000 100010 1101100 1100001 1100010 1101111 1110010 1110101 1101101 100010 111010 100000 1011011 110001 101100 100000 1011011 1011011 110100 101100 100000 110001 1011101 1011101 1011101 1111101



{'lorem': [1, [[1, 1]]], 'ipsum': [1, [[1, 1]]], 'dolor': [2, [[1, 1], [3, 1]]], 'sit': [1, [[1, 1]]], 'amet': [1, [[1, 1]]], 'consectetur': [1, [[2, 1]]], 'adipiscing': [1, [[2, 1]]], 'elit': [1, [[2, 1]]], 'sed': [1, [[2, 1]]], 'eiusmod': [1, [[2, 1]]], 'tempor': [1, [[2, 1]]], 'incididunt': [1, [[2, 1]]], 'ut': [1, [[2, 3], [2, 3], [2, 3]]], 'labore': [1, [[2, 1]]], 'et': [1, [[2, 1]]], 'dolore': [2, [[2, 1], [3, 1]]], 'magna': [1, [[2, 1]]], 'aliqua': [1, [[2, 1]]], 'enim': [1, [[2, 1]]], 'ad': [1, [[2, 1]]], 'minim': [1, [[2, 1]]], 'veniam': [1, [[2, 1]]], 'quis': [1, [[2, 1]]], 'nostrud': [1, [[2, 1]]], 'exercitation': [1, [[2, 1]]], 'ullamco': [1, [[2, 1]]], 'laboris': [1, [[2, 1]]], 'nisi': [1, [[2, 1]]], 'aliquip': [1, [[2, 1]]], 'ex': [1, [[2, 1]]], 'ea': [1, [[2, 1]]], 'commodo': [1, [[2, 1]]], 'consequat': [1, [[2, 1]]], 'duis': [1, [[3, 1]]], 'aute': [1, [[3, 1]]], 'irure': [1, [[3, 1]]], 'reprehenderit': [1, [[3, 1]]], 'voluptate': [1, [[3, 1]]], 'velit': [1, [[3, 1]]], 'esse': [1, [[3, 1]]], 'cillum': [1, [[3, 1]]], 'eu': [1, [[3, 1]]], 'fugiat': [1, [[3, 1]]], 'nulla': [1, [[3, 1]]], 'pariatur': [1, [[3, 1]]], 'excepteur': [1, [[4, 1]]], 'sint': [1, [[4, 1]]], 'occaecat': [1, [[4, 1]]], 'cupidatat': [1, [[4, 1]]], 'non': [1, [[4, 1]]], 'proident': [1, [[4, 1]]], 'sunt': [1, [[4, 1]]], 'culpa': [1, [[4, 1]]], 'qui': [1, [[4, 1]]], 'officia': [1, [[4, 1]]], 'deserunt': [1, [[4, 1]]], 'mollit': [1, [[4, 1]]], 'anim': [1, [[4, 1]]], 'id': [1, [[4, 1]]], 'est': [1, [[4, 1]]], 'laborum': [1, [[4, 1]]]}

Tags: thetoinjsonformatfordef二进制
1条回答
网友
1楼 · 发布于 2024-10-03 02:43:31

您可以使用[Python 3.Docs]: base64 — Base16, Base32, Base64, Base85 Data Encodingsb16encodeb16decode将字符串转换为适合4位chars)并结合一些字符串<;=>;int转换:

>>> import base64
>>> import json
>>>
>>> d0 = {'lorem': [1, [[1, 1]]], 'ipsum': [1, [[1, 1]]], 'dolor': [2, [[1, 1], [3, 1]]], 'sit': [1, [[1, 1]]], 'amet': [1, [[1, 1]]], 'consectetur': [1, [[2, 1]]], 'adipiscing': [1, [[2, 1]]], 'elit': [1, [[2, 1]]], 'sed': [1, [[2, 1]]], 'eiusmod': [1, [[2, 1]]], 'tempor': [1, [[2, 1]]], 'incididunt': [1, [[2, 1]]], 'ut': [1, [[2, 3], [2, 3], [2, 3]]], 'labore': [1, [[2, 1]]], 'et': [1, [[2, 1]]], 'dolore': [2, [[2, 1], [3, 1]]], 'magna': [1, [[2, 1]]], 'aliqua': [1, [[2, 1]]], 'enim': [1, [[2, 1]]], 'ad': [1, [[2, 1]]], 'minim': [1, [[2, 1]]], 'veniam': [1, [[2, 1]]], 'quis': [1, [[2, 1]]], 'nostrud': [1, [[2, 1]]], 'exercitation': [1, [[2, 1]]], 'ullamco': [1, [[2, 1]]], 'laboris': [1, [[2, 1]]], 'nisi': [1, [[2, 1]]], 'aliquip': [1, [[2, 1]]], 'ex': [1, [[2, 1]]], 'ea': [1, [[2, 1]]], 'commodo': [1, [[2, 1]]], 'consequat': [1, [[2, 1]]], 'duis': [1, [[3, 1]]], 'aute': [1, [[3, 1]]], 'irure': [1, [[3, 1]]], 'reprehenderit': [1, [[3, 1]]], 'voluptate': [1, [[3, 1]]], 'velit': [1, [[3, 1]]], 'esse': [1, [[3, 1]]], 'cillum': [1, [[3, 1]]], 'eu': [1, [[3, 1]]], 'fugiat': [1, [[3, 1]]], 'nulla': [1, [[3, 1]]], 'pariatur': [1, [[3, 1]]], 'excepteur': [1, [[4, 1]]], 'sint': [1, [[4, 1]]], 'occaecat': [1, [[4, 1]]], 'cupidatat': [1, [[4, 1]]], 'non': [1, [[4, 1]]], 'proident': [1, [[4, 1]]], 'sunt': [1, [[4, 1]]], 'culpa': [1, [[4, 1]]], 'qui': [1, [[4, 1]]], 'officia': [1, [[4, 1]]], 'deserunt': [1, [[4, 1]]], 'mollit': [1, [[4, 1]]], 'anim': [1, [[4, 1]]], 'id': [1, [[4, 1]]], 'est': [1, [[4, 1]]], 'laborum': [1, [[4, 1]]]}
>>>
>>> b16enc0 = base64.b16encode(json.dumps(d0).encode())  # Convert the string to bytes using utf8 (default)
>>> b16enc0
b'7B226C6F72656D223A205B312C205B5B312C20315D5D5D2C2022697073756D223A205B312C205B5B312C20315D5D5D2C2022646F6C6F72223A205B322C205B5B312C20315D2C205B332C20315D5D5D2C2022736974223A205B312C205B5B312C20315D5D5D2C2022616D6574223A205B312C205B5B312C20315D5D5D2C2022636F6E7365637465747572223A205B312C205B5B322C20315D5D5D2C202261646970697363696E67223A205B312C205B5B322C20315D5D5D2C2022656C6974223A205B312C205B5B322C20315D5D5D2C2022736564223A205B312C205B5B322C20315D5D5D2C2022656975736D6F64223A205B312C205B5B322C20315D5D5D2C202274656D706F72223A205B312C205B5B322C20315D5D5D2C2022696E6369646964756E74223A205B312C205B5B322C20315D5D5D2C20227574223A205B312C205B5B322C20335D2C205B322C20335D2C205B322C20335D5D5D2C20226C61626F7265223A205B312C205B5B322C20315D5D5D2C20226574223A205B312C205B5B322C20315D5D5D2C2022646F6C6F7265223A205B322C205B5B322C20315D2C205B332C20315D5D5D2C20226D61676E61223A205B312C205B5B322C20315D5D5D2C2022616C69717561223A205B312C205B5B322C20315D5D5D2C2022656E696D223A205B312C205B5B322C20315D5D5D2C20226164223A205B312C205B5B322C20315D5D5D2C20226D696E696D223A205B312C205B5B322C20315D5D5D2C202276656E69616D223A205B312C205B5B322C20315D5D5D2C202271756973223A205B312C205B5B322C20315D5D5D2C20226E6F7374727564223A205B312C205B5B322C20315D5D5D2C2022657865726369746174696F6E223A205B312C205B5B322C20315D5D5D2C2022756C6C616D636F223A205B312C205B5B322C20315D5D5D2C20226C61626F726973223A205B312C205B5B322C20315D5D5D2C20226E697369223A205B312C205B5B322C20315D5D5D2C2022616C6971756970223A205B312C205B5B322C20315D5D5D2C20226578223A205B312C205B5B322C20315D5D5D2C20226561223A205B312C205B5B322C20315D5D5D2C2022636F6D6D6F646F223A205B312C205B5B322C20315D5D5D2C2022636F6E736571756174223A205B312C205B5B322C20315D5D5D2C202264756973223A205B312C205B5B332C20315D5D5D2C202261757465223A205B312C205B5B332C20315D5D5D2C20226972757265223A205B312C205B5B332C20315D5D5D2C2022726570726568656E6465726974223A205B312C205B5B332C20315D5D5D2C2022766F6C757074617465223A205B312C205B5B332C20315D5D5D2C202276656C6974223A205B312C205B5B332C20315D5D5D2C202265737365223A205B312C205B5B332C20315D5D5D2C202263696C6C756D223A205B312C205B5B332C20315D5D5D2C20226575223A205B312C205B5B332C20315D5D5D2C2022667567696174223A205B312C205B5B332C20315D5D5D2C20226E756C6C61223A205B312C205B5B332C20315D5D5D2C20227061726961747572223A205B312C205B5B332C20315D5D5D2C2022657863657074657572223A205B312C205B5B342C20315D5D5D2C202273696E74223A205B312C205B5B342C20315D5D5D2C20226F63636165636174223A205B312C205B5B342C20315D5D5D2C2022637570696461746174223A205B312C205B5B342C20315D5D5D2C20226E6F6E223A205B312C205B5B342C20315D5D5D2C202270726F6964656E74223A205B312C205B5B342C20315D5D5D2C202273756E74223A205B312C205B5B342C20315D5D5D2C202263756C7061223A205B312C205B5B342C20315D5D5D2C2022717569223A205B312C205B5B342C20315D5D5D2C20226F666669636961223A205B312C205B5B342C20315D5D5D2C20226465736572756E74223A205B312C205B5B342C20315D5D5D2C20226D6F6C6C6974223A205B312C205B5B342C20315D5D5D2C2022616E696D223A205B312C205B5B342C20315D5D5D2C20226964223A205B312C205B5B342C20315D5D5D2C2022657374223A205B312C205B5B342C20315D5D5D2C20226C61626F72756D223A205B312C205B5B342C20315D5D5D7D'
>>>
>>> bits = " ".join("{0:04b}".format(int(chr(c), 16)) for c in b16enc0)
>>> len(bits)
15369
>>> bits[:0x9f]  # Print first 32 binary groups (as the whole thing is too long)
'0111 1011 0010 0010 0110 1100 0110 1111 0111 0010 0110 0101 0110 1101 0010 0010 0011 1010 0010 0000 0101 1011 0011 0001 0010 1100 0010 0000 0101 1011 0101 1011'
>>>
>>> # Now, the reverse
...
>>> b16enc1 = "".join("{0:X}".format(int(i, 2)) for i in bits.split())
>>> d1 = json.loads(base64.b16decode(b16enc1))
>>>
>>> d1
{'lorem': [1, [[1, 1]]], 'ipsum': [1, [[1, 1]]], 'dolor': [2, [[1, 1], [3, 1]]], 'sit': [1, [[1, 1]]], 'amet': [1, [[1, 1]]], 'consectetur': [1, [[2, 1]]], 'adipiscing': [1, [[2, 1]]], 'elit': [1, [[2, 1]]], 'sed': [1, [[2, 1]]], 'eiusmod': [1, [[2, 1]]], 'tempor': [1, [[2, 1]]], 'incididunt': [1, [[2, 1]]], 'ut': [1, [[2, 3], [2, 3], [2, 3]]], 'labore': [1, [[2, 1]]], 'et': [1, [[2, 1]]], 'dolore': [2, [[2, 1], [3, 1]]], 'magna': [1, [[2, 1]]], 'aliqua': [1, [[2, 1]]], 'enim': [1, [[2, 1]]], 'ad': [1, [[2, 1]]], 'minim': [1, [[2, 1]]], 'veniam': [1, [[2, 1]]], 'quis': [1, [[2, 1]]], 'nostrud': [1, [[2, 1]]], 'exercitation': [1, [[2, 1]]], 'ullamco': [1, [[2, 1]]], 'laboris': [1, [[2, 1]]], 'nisi': [1, [[2, 1]]], 'aliquip': [1, [[2, 1]]], 'ex': [1, [[2, 1]]], 'ea': [1, [[2, 1]]], 'commodo': [1, [[2, 1]]], 'consequat': [1, [[2, 1]]], 'duis': [1, [[3, 1]]], 'aute': [1, [[3, 1]]], 'irure': [1, [[3, 1]]], 'reprehenderit': [1, [[3, 1]]], 'voluptate': [1, [[3, 1]]], 'velit': [1, [[3, 1]]], 'esse': [1, [[3, 1]]], 'cillum': [1, [[3, 1]]], 'eu': [1, [[3, 1]]], 'fugiat': [1, [[3, 1]]], 'nulla': [1, [[3, 1]]], 'pariatur': [1, [[3, 1]]], 'excepteur': [1, [[4, 1]]], 'sint': [1, [[4, 1]]], 'occaecat': [1, [[4, 1]]], 'cupidatat': [1, [[4, 1]]], 'non': [1, [[4, 1]]], 'proident': [1, [[4, 1]]], 'sunt': [1, [[4, 1]]], 'culpa': [1, [[4, 1]]], 'qui': [1, [[4, 1]]], 'officia': [1, [[4, 1]]], 'deserunt': [1, [[4, 1]]], 'mollit': [1, [[4, 1]]], 'anim': [1, [[4, 1]]], 'id': [1, [[4, 1]]], 'est': [1, [[4, 1]]], 'laborum': [1, [[4, 1]]]}
>>>
>>> d1 == d0
True

我没有把它们封装在函数中,这很简单。你知道吗

相关问题 更多 >