【发布时间】:2019-04-01 18:38:17
【问题描述】:
您好,我正在使用 python marshmallow 包将 json 文件转换为 python 对象。但是其中一个键包含特殊字符。
from marshmallow import Schema
fakeJson = {"A":"33","$C":"12"}
class tempA:
def __init__(self,
A = None):
self.A = A
class tempASchema(Schema):
model = tempA
A = fields.Str()
result=tempASchema().load(fakeJson)
我正在尝试将元素“$C”转换为变量。但我不知道如何处理特殊字符“$”。
提前致谢。
【问题讨论】:
-
您遇到错误了吗?到底是什么问题?
-
json 支持...请追溯/错误
-
Marshmallow 不是解析 json 文件的工具。
marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes.来源:marshmallow.readthedocs.io/en/3.0 -
@aws_apprentice 我没有收到任何错误。我只想将“$C”转换为变量。但不知道如何在那里处理“$”。
-
变量名中不能有美元符号
标签: python marshmallow