(Python新手)写入文件打印什么?

(Python新手)写入文件打印什么?,python,gdata,Python,Gdata,多亏了这个网站的好意,我安装了2.7/setuptools/feedparser,一切都没有问题。。我已经找到了feedparser,它可以毫无问题地工作 我一直在阅读关于如何通过python编写文件(文本)的教程,我在使用文本编写方面取得了一定的成功。。然而,当我试图写一个数据列表时,它对我来说非常糟糕,什么都不做 原件: import feedparser result = feedparser.parse('https://gdata.youtube.com/feeds/api/vide

多亏了这个网站的好意,我安装了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频道上为即将到来的赠品收集评论。。如果有人想知道我用这些看似无用的数据做什么

致以最良好的祝愿,
-米奇·鲍威尔

这是你的实际代码吗
text\u file.write entry.author
在我看来不像Python。不,格式不正确。。我在那还有一行。。我会编辑的,对不起,凯文!。我是python新手,我过去唯一的“编程”经验是mIRC Automation的基本html和MSL。你说的“乱七八糟”是什么意思?
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)