Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created March 25, 2018 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/06e3d2315d58972181258217436972dc to your computer and use it in GitHub Desktop.
Save Fhernd/06e3d2315d58972181258217436972dc to your computer and use it in GitHub Desktop.
Uso de la función slice() en Python. OrtizOL.
registro = '....................100 .......513.25 ..........'
# Sin slice()
costo = int(registro[20:32]) * float(registro[40:48])
print(costo)
# Con slice()
cantidad = slice(20, 32)
valor = slice(40, 48)
costo = int(registro[cantidad]) * float(registro[valor])
print(costo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment