xml
1 2 3 | from xml.dom.minidom import * with open('d:/xml.txt', 'r') as f: print(parseString(f.read()).toprettyxml()) |
json
1 | python -m json.tool d:\json.txt |
下载文件
1 2 3 4 | import requests resp = requests.get('http://file.url', headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}) with open("aa.dat", "wb") as f: f.write(resp.content) |