我想按日期顺序打印来自Twitter日志的条目。我没有管理它们的日期进行排序,但我无法弄清楚如何显示近期/前100名Python排序,限制结果打印
下面的代码:下面提供
import codecs
with codecs.open('hoge_qdata.tsv','r', 'utf-8') as tweets:
tweet_list = tweets.readlines()
print tweet_list.pop(0).strip()
paired_tweets = sorted([ (int(t.split('\t')[2]), t) for t in tweet_list ], reverse=True)
for p in paired_tweets:
print p[1].encode('utf-8').strip()
数据文件... http://web.sfc.keio.ac.jp/~t12102ti/isc/tweetsample.zip
'用于paired_tweets P [100]'? –