Advertisement
Fhernd

lectura-escritura-texto-archivos.py

Jun 28th, 2018
1,785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import random as rnd
  2.  
  3. # Escritura sobre un archivo de texto:
  4. with open('python.txt', 'w', encoding='utf-8') as f:
  5.     for idx in range(1, 11):
  6.         f.write('{}\n'.format(idx))
  7.  
  8.  
  9. # Lectura del archivo de texto:
  10. with open('python.txt', 'r', encoding='utf-8') as f:
  11.     for linea in f:
  12.         print(linea, end='')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement