[Python] Using json.dumps(string) to dump a string

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

  1. Stack

    Stack Membro Participativo

    I want to put string into json.dumps()

    string = "{data}"

    print json.dumps(string)


    And I get:

    "{data}" instead of: {data}

    How I can get this string without quotes?

    Method replace:

    json.dumps(string.replace('"', '')


    or strip:

    json.dumps(string.strip('"')


    Does not work.

    Continue reading...

Compartilhe esta Página