1

私はpythonが初めてです...警告されています。

http://wiki.python.org/moin/RssLibrariesから例をコピーしましたが、エラーが発生し続けます

"future_calls = [Future(feedparser.parse,rss_url) for rss_url in hit_list]
TypeError: __init__() takes exactly 1 argument (3 given)"

これが私のコードです:

import feedparser
from futures import Future


hit_list = [ "http://feeds.reuters.com/news/artsculture", "http://feeds.reuters.com/reuters/healthNews" ] # list of feeds to pull down

# pull down all feeds
future_calls = [Future(feedparser.parse,rss_url) for rss_url in hit_list]
# block until they are all in
feeds = [future_obj() for future_obj in future_calls]

entries = []
for feed in feeds:
    entries.extend( feed[ "item" ] )
    sorted_entries = sorted(entries, key=lambda entry: entry["title"])
    print sorted_entries
4

1 に答える 1

1

正しいモジュールを使用していますか? あなたが持っている:

from futures import Future

ただし、リンク先のRssLibrariesページのモジュールを使用する場合は、

from future import Future

future(そして、そのページのリンクからモジュールをダウンロードする必要があります)。

以前のバージョンの Python 用の Python 3 モジュールのバックポートであるfutures モジュールを実際に使用しているようです。concurrent.futures

于 2012-04-17T02:05:38.047 に答える