擅长:python、mysql、java
<p>之所以发生<code>TypeError</code>,是因为您试图将两个参数传递给<code>choice</code>方法,而它只需要一个参数(隐式地加上<code>self</code>参数)。你知道吗</p>
<pre><code>if firstb == "Item":
S = []
l = len(S)
while l < rarPropTotal:
c = random.choice([Propstr], [Weightstr]) # error happens here!
S.append(c)
while S.contains(c):
c = random.choice(Propstr, Weightstr) # and here
S.append(c)
print("Property List: " + S)
</code></pre>
<p>线条应如下所示:</p>
<pre><code>c = random.choice([Propstr, Weightstr])
</code></pre>