Created
March 25, 2018 02:10
-
-
Save Fhernd/06e3d2315d58972181258217436972dc to your computer and use it in GitHub Desktop.
Uso de la función slice() en Python. OrtizOL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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