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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章