小编blu*_*173的帖子

如何将包含列表字符串的字节转换为Python对象?

我有一个bytes_start包含列表字符串的字节对象,我想将其转换为 Python 对象。

bytes_start = b'"[{\\"method\\": \\"NULLABLE\\", \\"title\\": \\"Customer\\", \\"type\\": \\"STRING\\"}, {\\"method\\": \\"NULLABLE\\", \\"title\\": \\"Vendor\\", \\"type\\": \\"INTEGER\\"}]"'
Run Code Online (Sandbox Code Playgroud)

我尝试使用new_bytes_start = json.dumps(bytes_start),但是没有用。如何使用 Python 3 获得以下结果?

new_bytes_start = [{"method": "NULLABLE", "title": "Customer", "type": "INTEGER"}, {"method": "NULLABLE", "title": "Vendor", "type": "FLOAT"}]
Run Code Online (Sandbox Code Playgroud)

python json python-3.x python-3.7

1
推荐指数
1
解决办法
8905
查看次数

标签 统计

json ×1

python ×1

python-3.7 ×1

python-3.x ×1