Problema con apertura de archivos
Publicado por Santiago (11 intervenciones) el 20/02/2020 15:07:13
Tengo el siguente código:
lo ejecuto y me dice esto:
Traceback (most recent call last):
File "old_pc_emulator.py", line 47, in <module>
open('ruta\\',nombreArchivo, 'r')
TypeError: an integer is required (got type str)
Lo cambié a int() y me dijo esto:
Traceback (most recent call last):
File "old_pc_emulator.py", line 47, in <module>
open('Ruta\\',int(nombreArchivo), 'r')
ValueError: invalid literal for int() with base 10: 'EjemploLectura.txt'
¿Qué hago mal?
1
2
nombreArchivo = input('Ingrese el nombre del archivo:\n')
open('C:\\Users\\Nombre de usuario\\Carpeta\\Subcarpeta\\',nombreArchivo, 'r')
Traceback (most recent call last):
File "old_pc_emulator.py", line 47, in <module>
open('ruta\\',nombreArchivo, 'r')
TypeError: an integer is required (got type str)
Lo cambié a int() y me dijo esto:
Traceback (most recent call last):
File "old_pc_emulator.py", line 47, in <module>
open('Ruta\\',int(nombreArchivo), 'r')
ValueError: invalid literal for int() with base 10: 'EjemploLectura.txt'
¿Qué hago mal?
Valora esta pregunta


0