對不起,發佈這樣一個天真的問題,但我只是無法弄清楚這一點。我已經寫了下面的條件語句:python if ... elif always not working
if taxon == "Bracelets":
catId = "178785"
elif taxon == "Kids Earrings" or "Earrings":
catId = "177591"
elif taxon == "Mangalsutras":
catId = "177595"
elif taxon == "Necklaces" or "Necklace Sets":
catId = "177597"
elif taxon == "Kids Pendants" or "Pendants":
catId = "177592"
elif taxon == "Pendant Sets":
catId = "177593"
elif taxon == "Anklets":
catId = "178788"
elif taxon == "Toe Rings":
catId = "178787"
elif taxon == "Rings":
catId = "177590"
else:
print "no match\n"
但無論怎樣類羣的價值是,它總是在第二個條件,即
elif taxon == "Kids Earrings" or "Earrings":
catId = "177591"
,因此,CATID的值保持177591
下降。
'elif的類羣== 「兒童耳環」 或類羣== 「耳環」:'否則第二個條件永遠是真 – reto
@MartijnPieters:真。但是,很難找到它,因爲問題的名稱沒有提示任何內容 – nish
沒關係,這是許多初學者遇到的問題,而沒有意識到發生了什麼問題。 –