[Python] tomlkit: nicely formatted array with inline tables

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use tomlkit 0.8.0 to create a TOML from the following data:

    data = {
    'stuff': [
    {'a':1, 'b': 2},
    {'c': 3},
    {'a': 4},
    ]
    }


    in this format exactly:

    stuff = [
    {a = 1, b = 2},
    {c = 3},
    {a = 4},
    ]


    A simpleprint(tomlkit.dumps(data)) creates:

    [[stuff]]
    a = 1
    b = 2

    [[stuff]]
    c = 3

    [[stuff]]
    a = 4


    How can this be done is a simple way?

    Continue reading...

Compartilhe esta Página