【发布时间】:2016-04-04 19:33:55
【问题描述】:
我写了json配置文件:
{
"file": {"file_name": "file.xls"},
"names1":
{"Joe Allen": "JOE",
"Leo Messi": "MESSI"}
}
它是格式化和可读的。我使用函数来更改文件名:
def plik(self, evt):
wildcard = "MS excell (*.xls)|*.xls"
dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), "", wildcard, wx.OPEN)
if dialog.ShowModal() == wx.ID_OK:
config['file'] = {'file_name': dialog.GetFilename()}
with open('config.json', 'w') as f:
json.dump(config, f)
self.Destroy()
frame = Program()
frame.Show()
修改后的 json 文件文本如下:
{"file": {"file_name": "file.xls"},"names1":{"Joe Allen": "JOE","Leo Messi": "MESSI"}}
我应该怎么做才能继续格式化。
【问题讨论】: