Created
January 15, 2019 04:54
-
-
Save parzibyte/c54aeeaed81f38077b064cc2e9df06ae to your computer and use it in GitHub Desktop.
Ejemplos de uso de splitext created by parzibyte - https://repl.it/@parzibyte/Ejemplos-de-uso-de-splitext
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
""" | |
Extraer u obtener la extensión | |
de un archivo en Python usando | |
os.path | |
@author parzibyte | |
""" | |
import os.path | |
archivos = [ | |
"Free Bird.mp3", "Maggie.png", "/home/parzibyte/main.go", | |
"C:\\users\\usuario\\Desktop\\Servidor.java", "Hola", ".env", "", | |
"hola.php", "////////", "." | |
] | |
for archivo in archivos: | |
nombre, extension = os.path.splitext(archivo) | |
print("El archivo '{}' se llama '{}' y tiene la extensión '{}'".format( | |
archivo, nombre, extension)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment