from urllib.request import urlopen
page1 = urlopen("http://www.beans-r-us.biz/prices.html")
page2 = urlopen("http://www.beans-r-us.biz/prices-loyalty.html")
text1 = page1.read().decode("utf8")
text2 = page2.read().decode("utf8")
where = text2.find(">$")
start_of_price = where + 2
end_of_price = where + 6
price_loyal = text2[start_of_price:end_of_price]
price = text1[234:238]
password = 5501
p = input("Loyalty Customers Password? : ")
passkey = int(p)
if passkey == password:
while price_loyal > 4.74:
if price_loyal < 4.74:
print("Here is the loyal customers price :) :")
print(price_loyal)
else:
print("Price is too high to make a profit, come back later :) ")
else:
print("Sorry incorrect password :(, here is the normal price :")
print(price)
input("Thanks for using our humble service, come again :), press enter to close this window.")
Das Problem, das ich habe, ist, dass es läuft, bis ich den 4,74 Teil bekomme. Dann hört es auf und beschwert sich über einen unbeständigen Typ. Ich bin völlig verwirrt, was das bedeutet.Was bedeutet der Fehler Unorderable Type in Python?
Worüber beklagt es sich? – dukevin
Ist 'price_loyal' kein String (selbst wenn er Zahlen enthält, die Sie mit' find' gefunden haben), die Sie dann mit einem numerischen Wert (4.75) vergleichen wollen? Was passiert, wenn Sie 'float (price_royal)' versuchen – Levon
Im Gegensatz zu anderen gängigen Skriptsprachen ist Python streng typisiert. Wenn Sie also eine Zeichenfolge in eine Zahl konvertieren möchten, müssen Sie dies explizit tun. –