Fhernd icon

manipulaciones-rutas.py

Fhernd | PRO | 07/11/18 12:02:34 PM UTC | 0 ⭐ | 3010 👁️ | Never ⏰ | []
Python |

450 B

|

None

|

0 👍

/

0 👎

import os
 
ruta = "D:\\Dropbox\\Pro\\Recetas\\Python3\\venv\Ch05\\fibonaccis.txt"
 
# Nombre del archivo:
print(os.path.basename(ruta))
 
# Nombre del directorio:
print(os.path.dirname(ruta))
 
# Partes de la ruta:
print(os.path.join('temporal', 'datos', os.path.basename(ruta)))
 
# Concatenar con la ruta de usuario:
ruta = '~\\Archivos\\datos.csv'
print(os.path.expanduser(ruta))
 
# Obtener extensión y ruta:
print(os.path.splitext(ruta))

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎