0

このウェブサイトの親切のおかげで、2.7/setuptools/feedparser をすべて問題なくインストールできました。feedparser を見つけたところ、問題なく動作します。

私はpython経由でファイル(テキスト)に書き込む方法に関するチュートリアルを読んできましたが、テキストでこれを行うことで中程度の成功を収めました..しかし、データのリストを書き込もうとすると、すべて面倒になり、何もしません全て。

オリジナル:

import feedparser

result = feedparser.parse('https://gdata.youtube.com/feeds/api/videos/Ej4_G-E1cAM/comments')
for entry in result.entries:
print entry.author

私の試み:

import feedparser

result = feedparser.parse('https://gdata.youtube.com/feeds/api/videos/Ej4_G-E1cAM/comments')
for entry in result.entries:
with open("write.txt", "w") as text_file:
text_file.write entry.author

私は、私の YouTube チャンネルで今後のプレゼント用にコメントを収集しようとしています.. この一見役に立たないデータを何に使用しているのか疑問に思っている人がいたら.

よろしく、 -ミッチ・パウエル

4

1 に答える 1

0
import feedparser
f = open('filename','w')
result = feedparser.parse('https://gdata.youtube.com/feeds/api/videos/Ej4_G-E1cAM/comments')
for entry in result.entries:
    f.write(entry.author)
于 2013-04-04T20:04:18.117 に答える