python json.dump()與json.load()

import json
#json.dump()
'''
numbers = [2,3,4,7,11,13]
with open(file_name,'w') as f_obj:
json.dump(numbers, f_obj)#存入到指定文件第一個參數爲要存入的內容,第二個爲文件的對象
''' 
#json.load()        
'''  
with open(file_name) as f_obj:
numbers = json.load(f_obj)#取得指定文件中內容,參數爲要讀取的文件對象
print(numbers)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章