Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Tue Mar 19 23:33:48 2019
- @author: jhongesell
- """
- # Fuente: http://elclubdelautodidacta.es/wp/tag/python/page/4/
- # Python: Aprendiendo a escribir
- # fichero = open('arreglo_N02_V01.txt')
- # fichero = open('arreglo_N02_V01.txt', 'rt')
- # fichero = open('arreglo_N02_V01.txt', 'r')
- fichero = open('arreglo_N02_V02.txt', 'w')
- print(type(fichero))
- # fichero.read()
- print(fichero.write('Serie: La casa de la pradera\nAÑo: ni lo recuero, \yo era pequeño\n\n¿La repondrán? '))
- print(fichero.write('Quién sabe.'))
- fichero.close()
- print('**********')
- a = ['Litio\n', 'Sodio\n', 'Potasio\n']
- fichero = open('prueba2.txt', 'w')
- for elemento in a:
- print(fichero.write(elemento))
- fichero.close()
- print('**********')
- b = ['Fluor', 'Cloro', 'Bromo', 'Iodo']
- fichero = open('prueba3.txt', 'w')
- for elemento in b:
- print(fichero.write(elemento + '\n'))
- fichero.close()
- print('**********')
- c = ['Fluor', 'Cloro', 'Bromo', 'Iodo']
- fichero = open('prueba4.txt', 'w')
- for elemento in c:
- print(fichero.write('%s\n' % elemento))
- fichero.close()
- print('**********')
- print(a)
- fichero = open('prueba5.txt', 'w')
- fichero.writelines(a)
- fichero.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement