擅长:python、mysql、java
<p>请尝试以下操作。你知道吗</p>
<pre><code>if attrs.hasKey("weight"):
w = attrs.getValue("weight")
self.edgeweight = w
</code></pre>
<p>我使用<a href="https://docs.python.org/2/library/xml.sax.reader.html#attributes-objects" rel="nofollow">this</a>作为参考。它没有指定您是否可以使用<code>"weight" in attrs</code>,但是您可以尝试看看它是否有效。你知道吗</p>