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(),数据会在屏幕上打印出来.但它不会被转储到文件中.
文件被创建但在打开它时(使用记事本),什么都没有.为什么?
怎么纠正呢?
我执行了以下命令:
find . name "myfile.txt"
但这显示了冗长的信息.
如何解释这个冗长?