下面是我的代码:
import requests
html = requests.get(
html_str = html.content
Html_file= open("fb_remodel.txt",'w')
Html_file.write(html_str)
Html_file.close()
这会产生一个文本文件
{"data":[{"id":"359434924192565_361115077357883","created_time":"2013-11-05T18:52:24+0000"},{"id":"116929191671920_664658976898936","created_time":"2013-11-05T18:51:57+0000"},
我希望在每个 }, 之后都有一个换行符。
请您参考如下方法:
您可以使用 Python 的“json”模块“漂亮地打印”JSON
参见:http://docs.python.org/2/library/json.html
pretty-print :
import json
print json.dumps({'4': 5, '6': 7}, sort_keys=True,
... indent=4, separators=(',', ': '))
{
"4": 5,
"6": 7
}
