Wie ein Bult-in-Dict in Redis festgelegt hatPython

Python-Programme
Anonymous
 Wie ein Bult-in-Dict in Redis festgelegt hat

Post by Anonymous »

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

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post