擅长:python、mysql、java
<p>必须使用<code>or</code>而不是<code>|</code>:</p>
<pre><code>def charismamod(cha):
chamod = 0
if cha == 1:
chamod = -5
elif cha == 2 or cha == 3:
chamod = -4
elif cha == 4 or cha == 5:
chamod = -3
elif cha == 6 or cha == 7:
chamod = -2
elif cha == 8 or cha == 9:
chamod = -1
elif cha == 10 or cha == 11:
chamod = 0
elif cha == 12 or cha == 13:
chamod = 1
elif cha == 14 or cha == 15:
chamod = 2
elif cha == 16 or cha == 17:
chamod = 3
elif cha == 18 or cha == 19:
chamod = 4
elif cha == 20:
chamod = 5
return chamod
def barbarian():
cha = 14
bchamod = charismamod(cha)
print bchamod
barbarian()
</code></pre>
<p><code>|</code>是位运算符。必须使用<code>or</code>或<code>||</code>。你知道吗</p>
<blockquote>
<p>x | y</p>
<p>Does a "bitwise or". Each bit of the output is 0 if the corresponding
bit of x AND of y is 0, otherwise it's 1.</p>
</blockquote>
<p><a href="https://wiki.python.org/moin/BitwiseOperators" rel="nofollow">BitwiseOperators</a></p>