小编Art*_*Art的帖子

如何将数据序列化为缩进的json

我正在使用此代码将用户序列化为json文本文件.

if (File.Exists(path))
{
    using (var file = File.CreateText(path))
    {
        var serializer = new JsonSerializer();
        serializer.Serialize(file, this.users);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的结果:

[输出]

我怎样才能得到这样的结果:

[漂亮地打印]

c# json file

5
推荐指数
2
解决办法
4654
查看次数

Google API 凭据刷新失败

这是我的代码的一部分:

 if os.path.exists('token.pickle'):
                with open('token.pickle', 'rb') as token:
                    creds = pickle.load(token)
            if not creds or not creds.valid:
                if creds and creds.expired and creds.refresh_token:
                    creds.refresh(Request())
Run Code Online (Sandbox Code Playgroud)

如果信用证过期,则必须刷新。在 Windows 上这部分工作,但在 Linux 上我得到一个错误(在最后一个字符串上):

('invalid_scope: Some requested scopes were invalid. {invalid=[a, c, d, e, g, h, i, l, m, ., /, o, p, r, s, t, u, v, w, :]}', '{\n  "error": "invalid_scope",\n  "error_description": "Some requested scopes were invalid. {invalid\\u003d[a, c, d, e, g, h, i, l, m, ., /, o, p, r, s, t, …
Run Code Online (Sandbox Code Playgroud)

python credentials google-api google-drive-api

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

标签 统计

c# ×1

credentials ×1

file ×1

google-api ×1

google-drive-api ×1

json ×1

python ×1