elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Saber si un archivo existe en python.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Saber si un archivo existe en python.  (Leído 10,419 veces)
desnight

Desconectado Desconectado

Mensajes: 35



Ver Perfil
Saber si un archivo existe en python.
« en: 3 Mayo 2008, 17:48 pm »

¿Sabes si hay algun comando en python parecido al "exist" de batch?
 
Saludos.


En línea

Que es mi barco mi tesoro,
que es mi dios la libertad,
mi ley, la fuerza y el viento,
mi única patria, la mar.
dooque

Desconectado Desconectado

Mensajes: 170



Ver Perfil
Re: Saber si un archivo existe en python.
« Respuesta #1 en: 17 Mayo 2008, 04:58 am »

import os.path

os.path.isfile(nombre_del_archivo)

esa te devuelvetrue si la cadena q toma como argumento es un archivo! si no existe te devuelvw false supongo jeje, si eso no te sirve proba usar la funcion stat() que esta en el modulo os

saludos


En línea

Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.  -- Kernighan
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Python]Formas de saber si una palabra es palindromo
Python
0x5d 2 23,093 Último mensaje 26 Abril 2012, 01:19 am
por 0x5d
[AYUDA][PYTHON] Como saber dia de la semana
Scripting
Noxware 7 15,478 Último mensaje 28 Septiembre 2014, 06:13 am
por Eleкtro
Existe la encapsulacion en python??
Scripting
15-19 2 2,455 Último mensaje 2 Mayo 2017, 06:51 am
por 15-19
[Python 3]Archivo no encontrado cuando si existe
Python
n1sen 3 2,862 Último mensaje 23 Octubre 2017, 13:51 pm
por engel lex
[Python 3]Saber codificacion de un archivo de texto
Python
n1sen 4 5,533 Último mensaje 3 Diciembre 2017, 19:52 pm
por Eleкtro
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines