少妇精品导航,人妻巨大乳一二三区,欧美性白人极品1819hd,亚洲日韩AV一区二区三区中文

Section Menu:  

字典存儲(chǔ)為json文件函數(shù):dict2json_file()

  • 發(fā)布時(shí)間: 2019-08-28 00:00
  •    閱讀: 2787   

描述

dict2json_file() 將字典存儲(chǔ)為json文件。
dict2json_file() 接收兩個(gè)參數(shù),第一個(gè)參數(shù)為要存儲(chǔ)的數(shù)據(jù),第二個(gè)參數(shù)為存放的路徑+文件名。


 
語(yǔ)法

以下是 dict2json_file() 的語(yǔ)法:

dict2json_file(dict, file='temp/temp.json')

參數(shù)

    ● dict [dict]:要存儲(chǔ)的字典數(shù)據(jù)。
    ● file [str]:要儲(chǔ)存的路徑+文件名。


返回值

無(wú)返回值。


實(shí)例

以下展示了使用 dict2json_file() 的實(shí)例:

from kyger.utility import dict2json_file
print(dict2json_file({"name": "kgcms", "www": "http://www.gyssny.cn"}, file='static/kgcms.json'))  # 將字典轉(zhuǎn)成json寫入到文件

以上實(shí)例運(yùn)行后輸出的結(jié)果為:

# static/kgcms.json文件內(nèi)容:{"name": "kgcms", "www": "http://www.gyssny.cn"}

適應(yīng)版本

v1.0.1