2016-04-04 12 views
0

は、私は、JSONの設定ファイルを書きました。PythonのJSON設定ファイル

{"file": {"file_name": "file.xls"},"names1":{"Joe Allen": "JOE","Leo Messi": "MESSI"}} 

私は整形を保つために何をすべき:JSONファイルの変更のテキストがどのように見えるの後

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() 

:私はFILE_NAMEを変更する機能を使用しています。

答えて

0

私はjson.dump(config, f, sort_keys=True, indent=2)で行っています。ここにはインデントがありました。シンプルなソリューション。

関連する問題