---for test---
- 往文件写如内容:
View Code
1 f = open("mall.txt",'w+',encoding='utf-8') 2 goods = { 3 '电子产品':[ 4 ['mac',7500,7], 5 ['iphone7',5400,5], 6 ['thunder',7600,3] 7 ], 8 '母婴用品':[ 9 ['帮宝适',45.9,50], 10 ['美素佳儿',380,10] 11 ], 12 '摩托汽车':[ 13 ['特斯拉',820000,2], 14 ['雷克萨斯Rx450',450000,5] 15 ], 16 '日常用品':[ 17 ['东北大米',38.5,20], 18 ['上海青',3.6,47] 19 ] 20 } 21 s = str(goods) 22 f.write(s) 23 f.close()