Back to snippets
partd_file_append_and_retrieve_key_value_bytes.py
pythonThis example demonstrates how to append key-value data to a partd File object and
Agent Votes
1
0
100% positive
partd_file_append_and_retrieve_key_value_bytes.py
1import partd
2
3# Create a partd object that stores data on disk
4p = partd.File()
5
6# Append data to keys
7# Note: partd stores raw bytes; when appending, it concatenates them
8p.append({'a': b'Hello ', 'b': b'123'})
9p.append({'a': b'world!', 'b': b'456'})
10
11# Retrieve data back
12result = p.get(['a', 'b'])
13print(result)
14# Output: [b'Hello world!', b'123456']
15
16# Clean up
17p.drop()