【发布时间】:2022-01-04 20:40:27
【问题描述】:
所以我有一些需要自动格式化的标题。我一直是手动完成的,现在越来越无聊,我正在寻找一种自动完成的方法。我曾尝试使用 Python 内置格式,但没有奏效。
这些是标题:
headers = {
authority: discord.com
method: POST
path: /api/v9/auth/register
scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
content-length: 2840
content-type: application/json
origin: https://discord.com
referer: https://discord.com/register
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
x-debug-options: bugReporterEnabled
x-discord-locale: en-US
}
我希望像这样格式化它们:
"authority": "discord.com",
"method": "POST",
"path": "/api/v9/auth/register",
【问题讨论】:
-
具体是什么意思?
-
您使用的是 IDE 吗?也许是 PyCharm?
-
是的,我正在使用 PyCharm
-
@ScottHunter 它基本上没有做任何事情。添加一些空格,就是这样。
-
我将为您发布一个修复程序。请给我一点时间。
标签: python python-3.x formatting format