小编use*_*662的帖子

如何解决AttributeError:'NoneType'对象在python中没有属性'encode'

for comment_entry in comment_feed.entry:
content = comment_entry.ToString()
parse = BeautifulSoup(content)
for con in parse.find('ns0:content'):
    print con.string
    s = con.string
    file.write(s.encode('utf8'))
Run Code Online (Sandbox Code Playgroud)

我得到的错误:

File "channel_search.py", line 108, in youtube_search
file.write(s.encode('utf8'))
AttributeError: 'NoneType' object has no attribute 'encode'
Run Code Online (Sandbox Code Playgroud)

python file beautifulsoup

8
推荐指数
1
解决办法
3万
查看次数

标签 统计

beautifulsoup ×1

file ×1

python ×1