gpt4 book ai didi

php - JSON格式化额外字符

转载 作者:太空宇宙 更新时间:2023-11-04 03:28:53 27 4
gpt4 key购买 nike

我正在尝试通过 API 使用 Python 发送一些 JSON。它有效,但它添加了一堆时髦的字符,我不知道为什么或它们的意思。

我正在做的是转换这个“body”变量:

+++[git checkout hashhashhash]+++

+++[git diff --name-status master]+++

M file.php

1 files changed.

为此:

body = {"body":"{{noformat}}{0}{{noformat}}".format(body)}

完成后,'body' 变成这样:

{'body': '{noformat}\n+++[git checkout hashashashashash]+++\n+++[git diff --name-status master]+++\n\x1b[?1h\x1b=M       file.php\x1b[m\r\n\r\x1b[K\x1b[?1l\x1b>\n1 files changed.\n{noformat}'}

这完全没问题,除了这是通过 API 发送后发布的内容:

+++[git checkout hashashashashashash]+++

+++[git diff --name-status master]+++

[?1h=M file.php[m

[K[?1l>
1 files changed.

我还没有弄清楚是怎么回事。 [?1h=M[K[?1l> 有何关系,如何让它们消失?

最佳答案

我想您会发现这些是 git 发送的终端初始化序列 - function-key-mode onfunction-key-mode off 是准确的。

在生成原始 Git 输出时尝试使用 --no-pager 选项。

关于php - JSON格式化额外字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31951738/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com