小编use*_*411的帖子

json.dumps()无效

import json

def json_serialize(name, ftype, path):

        prof_info = []

        prof_info.append({
            'profile_name': name,
            'filter_type': ftype
        })

        with open(path, "w") as f:
            json.dumps({'profile_info': prof_info}, f)

json_serialize(profile_name, filter_type, "/home/file.json")
Run Code Online (Sandbox Code Playgroud)

上面的代码不会将数据转储到"file.json"文件中.当我print以前写的时候json.dumps(),数据会在屏幕上打印出来.但它不会被转储到文件中.

文件被创建但在打开它时(使用记事本),什么都没有.为什么?

怎么纠正呢?

json python-2.7

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

如何在ubuntu中隐藏"find"命令的详细信息?

我执行了以下命令:

find . name "myfile.txt"

但这显示了冗长的信息.

如何解释这个冗长?

linux shell ubuntu-13.04

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

标签 统计

json ×1

linux ×1

python-2.7 ×1

shell ×1

ubuntu-13.04 ×1