5. Los datos de Python son inteligentes¶
Los lenguajes de programación proporcionan funcionalidades incorporadas en los datos para ayudarte.
Los datos de Python son inteligentes: pueden hacer cosas.
Print output (drag lower right corner to resize)
|
Activity: CodeLens 5.1 (cl_l33_5a)
5.1. Método find
¶
Método
find
para strings
Print output (drag lower right corner to resize)
|
Activity: CodeLens 5.1.1 (cl_l33_5b)
10
from urllib.request import urlopen
URL_PRECIOS_LOYALTY = "https://api.allorigins.win/raw?url=http://beans.itcarlow.ie/prices-loyalty.html"
pagina = urlopen(URL_PRECIOS_LOYALTY)
texto = pagina.read()
ubicacion = texto.find(">$")
inicio = ubicacion + 2
fin = inicio + 4
print(texto[inicio:fin])
Activity: 5.1.2 ActiveCode (ac_l33_5)
You have attempted 1 of 3 activities on this page