Python 将 JSON 对象转换为字符串
在 Python 中,你可以使用 json.dumps() 函数将 JSON 对象转换为字符串。以下是一个示例:
import json
# JSON 对象
data = {
'name': 'John',
'age': 30,
'city': 'New York'
}
# 将 JSON 对象转换为字符串
json_string = json.dumps(data)
print(json_string)
输出:
{'name': 'John', 'age': 30, 'city': 'New York'}
AI 优化版
原文地址:https://www.cveoy.top/t/topic/oia4 著作权归作者所有。请勿转载和采集!