Jump to content

Converter ficheiros Python ou JSON e vice versa: Problema relacionado com trailing data ou simplesmente da plataforma de visualização?


jonhhy

Recommended Posts

Bom dia comunidade P@P,

tenho dúvida relacionada com o não reconhecimento dos caracteres \n (newline) 5MLM7C6.png .

 

Disponível neste código:  https://github.com/ManJ-PC/PExercises/blob/main/Json.ipynb   ou

# Dicionário em Python
client = {
    "name": "Nora",
    "age": 56,
    "id": "45355",
    "eye_color": "green",
    "wears_glasses": False
}

# Obter uma string formatada em JSON
client_JSON = json.dumps(client)
client_JSON_B = json.dumps(client, sort_keys=True, indent=4 )
client_JSON_B

O output foi:

'{\n "age": 56,\n "eye_color": "green",\n "id": "45355",\n "name": "Nora",\n "wears_glasses": false\n}',

em vez de:

{

    "age": 56,

    "eye_color": "green",

    "id": "45355",

    "name": "Nora",

    "wears_glasses": false

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.