[英]How to make each tweet on its own line?
I am wanting to have each tweet be on its own line. 我想让每条推文都在自己的路线上。
Currently, this breaks at each response (I listed Response_1...I am using through Response_10) 目前,每个响应都会中断(我列出了Response_1 ......我通过Response_10使用)
Any ideas? 有任何想法吗?
#!/usr/bin/env python
import urllib
import json
response_1 = urllib.urlopen("http://search.twitter.com/search.json?q=microsoft&page=1")
for i in response_1:
print (i, "\n")
You have to parse the json as a python object first, only then you can iterate over it. 您必须首先将json解析为python对象,然后才能迭代它。
#!/usr/bin/env python
import urllib
import json
response_1 = json.loads(urllib.urlopen("http://search.twitter.com/search.json?q=microsoft&page=1").read())
for i in response_1['results']:
print (i, "\n")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.