Advertisement
Sergio_Istea

ficcheros

May 15th, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # PErmisos
  2. # r lectura
  3. # w escritura (crea y sobre escribe)
  4. # a append (añade lineas al fichero)
  5.  
  6. # Abrimos un archivo para obetner el numero de lineas
  7. objeto_archivo = open("/etc/passwd", "r")
  8.  
  9. num_lineas = len(list(objeto_archivo))
  10.  
  11.  
  12. # cerramos el archivo
  13. objeto_archivo.close()
  14.  
  15.  
  16.  
  17. # Abrimos el archivo para procesar sus lineas.
  18.  
  19. objeto_archivo = open("/etc/passwd", "r")
  20.  
  21. linea = 1
  22. while linea <= num_lineas:
  23.  
  24. campos_passwd = objeto_archivo.readline().split(":")
  25.  
  26. print(campos_passwd)
  27.  
  28. linea += 1
  29.  
  30.  
  31. objeto_archivo.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement