python的json应用 ————数据存储

import  json
numbers=[1,2,3,4,5,6]
filename='numbers.json'
with  open (filename,'w') as file_object:
    json.dump(numbers,file_object)

存数据

import  json
filename='numbers.json'
with  open(filename) as f_obj:
    numbers=json.load(f_obj)

print(numbers)

读数据

猜你喜欢

转载自www.cnblogs.com/liuzhaojun/p/10840596.html
今日推荐