sample_python_cbor_enc.py 286 B

1234567891011121314
  1. import cbor
  2. data = {
  3. "name": "python-cbor",
  4. "versions": ["1", "2"],
  5. "group": {
  6. "is_a_package": True,
  7. "value": 42
  8. }
  9. }
  10. serialized = cbor.dumps(data)
  11. print(serialized.decode(errors="ignore"))
  12. with open("/tmp/data.cbor", "wb") as f:
  13. f.write(serialized)