PYTHONL Telegram 5087
This media is not supported in your browser
VIEW IN TELEGRAM
⚡️КРАСИВЫЙ JSON ИЗ СЛОВАРЯ ЗА 1 СТРОКУ

Сегодня разберём крутую и полезную фишку — как с помощью Python одной строчкой красиво форматировать словарь в JSON с отступами.


import json

data = {
"user": "Alice",
"age": 30,
"skills": ["Python", "Docker", "ML"],
"active": True,
"projects": {
"current": "Chatbot",
"next": "Data Pipeline"
}
}


pretty_json = json.dumps(data, indent=4, ensure_ascii=False)
print(pretty_json)

Это особенно удобно при отладке, логировании или подготовке данных для API. Больше не нужно вручную настраивать pprint — просто используй json.dumps с параметрами indent и ensure_ascii!
16👍5🔥1😁1



tgoop.com/pythonl/5087
Create:
Last Update:

⚡️КРАСИВЫЙ JSON ИЗ СЛОВАРЯ ЗА 1 СТРОКУ

Сегодня разберём крутую и полезную фишку — как с помощью Python одной строчкой красиво форматировать словарь в JSON с отступами.


import json

data = {
"user": "Alice",
"age": 30,
"skills": ["Python", "Docker", "ML"],
"active": True,
"projects": {
"current": "Chatbot",
"next": "Data Pipeline"
}
}


pretty_json = json.dumps(data, indent=4, ensure_ascii=False)
print(pretty_json)

Это особенно удобно при отладке, логировании или подготовке данных для API. Больше не нужно вручную настраивать pprint — просто используй json.dumps с параметрами indent и ensure_ascii!

BY Python/ django


Share with your friend now:
tgoop.com/pythonl/5087

View MORE
Open in Telegram


Telegram News

Date: |

On June 7, Perekopsky met with Brazilian President Jair Bolsonaro, an avid user of the platform. According to the firm's VP, the main subject of the meeting was "freedom of expression." Joined by Telegram's representative in Brazil, Alan Campos, Perekopsky noted the platform was unable to cater to some of the TSE requests due to the company's operational setup. But Perekopsky added that these requests could be studied for future implementation. How to create a business channel on Telegram? (Tutorial) Choose quality over quantity. Remember that one high-quality post is better than five short publications of questionable value. Channel login must contain 5-32 characters
from us


Telegram Python/ django
FROM American