标签:odi port 解码 imp dump object file obj import
#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
import json
file = open(‘a.txt‘,‘w‘)
for root,dirs,files in os.walk(‘./‘):
file.write(‘root:‘ + root + ‘\n‘)
file.write(‘dirs:‘ + json.dumps(dirs) + ‘\n‘)
#json.dumps(object) 编码(把object变成json型string) json.loads(string) 解码
file.write(‘files:‘ + json.dumps(files) + ‘\n‘)
file.write(‘\n‘)
file.close()
标签:odi port 解码 imp dump object file obj import
原文地址:https://www.cnblogs.com/guomengkai/p/11686818.html