Wie ein Bult-in-Dict in Redis festgelegt hat

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie ein Bult-in-Dict in Redis festgelegt hat

by Anonymous » 27 Mar 2025, 16:07

Ich möchte eine Struktur erstellen, die ähnlich ist wie: < /p>

Code: Select all

structure = {value: {key: item}, value : {key: item}}
< /code>
und [url=viewtopic.php?t=14917]ich möchte[/url] dies auf ähnliche Weise zu REDIS hinzufügen: < /p>
    mapping = {}
for i, (key, item) in enumerate(sorted(total_activs.items()), start=1):
mapping[i] = {key: item}

r.hset(f"{group}", json.dumps(mapping))
< /code>
Aber es funktioniert nicht. Aber warum?top = r.hmget(f"{group}", ['1', '2', '3'])
print(top) # return [{key_1: my_first_item}, {key_2: my_second_item}]

top[0][key_1] # my_first_item

Top