私は Python の初心者ですが、何が間違っていますか?
if p1_teller == 0 & p1_raw[0:1] != "/":
print "Loop 1"
else:
print "Loop 2"
次に、次のエラーが表示されます。
TypeError: &: 'int' および 'str' のサポートされていないオペランド型
私は Python の初心者ですが、何が間違っていますか?
if p1_teller == 0 & p1_raw[0:1] != "/":
print "Loop 1"
else:
print "Loop 2"
次に、次のエラーが表示されます。
TypeError: &: 'int' および 'str' のサポートされていないオペランド型
Python はand
論理積を使用します。&
はビットごとの andです。コードを次のように変更します。
if p1_teller == 0 and p1_raw[0:1] != "/":
print "Loop 1"
else:
print "Loop 2"
Google で簡単に検索すると、演算子に & ではなく「and」を使用している python が表示されます。
and
これを変更する代わりに使用し&
ます:
if p1_teller == 0 & p1_raw[0:1] != "/":
に :
if p1_teller == 0 and p1_raw[0:1] != "/":