擅长:python、mysql、java
<p>与其尝试分别分配channelname和tvguide,不如使用<code>split</code>方法返回的列表。在</p>
<pre><code>for channel in tree.findall("channel"):
title = channel.find('title').text
description = title.split("[")
print description
</code></pre>
<p>这样,您就不必担心频道是否有名称或tvguide,但要确保在channel对象中得到一个字符串。在</p>
<p><code>as Jon Clements suggested, we still need to figure out if its allowed to access description[1] and as he suggested an elegant way to do is str.partition</code></p>
^{pr2}$