Python-JSON文件编写

2024-05-14 06:50:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试用python脚本编写一个JSON文件我有以下几点:

#write JSON file:
data = {
   'description' : 'ACME',
   'taskType' : 100,
   'scanFileTypes' : 542.23,
   'connections' : connectionName,
   'fileTypeExclude' : False,
   'policies': 'PCI_Hadoop'
}



with open(jsonPropPath, 'w') as outfile:
    json.dump(data, outfile, ensure_ascii=False)

我的JSON文件如下所示:

cat/home/matt/DGagent/jsonFile_.json目录

{"description": "ACME", "scanFileTypes": 542.23000000000002, "connections": "dgcl_20150805102636", "policies": "PCI_Hadoop", "taskType": 100, "fileTypeExclude": false}[matt@server1 ~]

正如您所看到的,小数点正在扩展,它还添加了服务器:[马特@服务器1~]

有人能帮我纠正这些问题吗?你知道吗


Tags: 文件hadoopjsonfalsedatadescriptionconnectionsoutfile

热门问题