pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/mouredev/Hello-Python/commit/50ddfc71987b74da2bb722fefba82180411ba1bc

ss" /> Correcciones curso intermedio · mouredev/Hello-Python@50ddfc7 · GitHub
Skip to content

Commit 50ddfc7

Browse files
committed
Correcciones curso intermedio
1 parent 95d24ed commit 50ddfc7

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

Intermediate/06_file_handling.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,43 @@
1010
# .txt file
1111

1212
# Leer, escribir y sobrescribir si ya existe
13-
txt_file = open("Intermediate/my_file.txt", "w+")
13+
txt_file = open("my_file.txt", "w+")
1414

1515
txt_file.write(
1616
"Mi nombre es Brais\nMi apellido es Moure\n35 años\nY mi lenguaje preferido es Python")
1717

18-
# print(txt_file.read())
18+
# Posiciona el cursor al inicio del fichero
19+
txt_file.seek(0)
20+
21+
# Lee e imprime todo el contenido del fichero
22+
print(txt_file.read())
23+
24+
# Lee e imprime 10 caracteres desde el inicio del fichero
25+
txt_file.seek(0)
1926
print(txt_file.read(10))
27+
28+
# Lee e imprime el resto de la línea actual desde la posición 11
2029
print(txt_file.readline())
30+
31+
# Lee e imprime la siguiente línea
2132
print(txt_file.readline())
33+
34+
# Lee e imprime las líneas restantes del fichero
2235
for line in txt_file.readlines():
2336
print(line)
2437

38+
# Escribe una nueva línea en el fichero
2539
txt_file.write("\nAunque también me gusta Kotlin")
26-
print(txt_file.readline())
2740

41+
# Posiciona el cursor al inicio del fichero, lee e imprime todo su contenido
42+
txt_file.seek(0)
43+
print(txt_file.read())
44+
45+
# Cierra el fichero
2846
txt_file.close()
2947

30-
with open("Intermediate/my_file.txt", "a") as my_other_file:
48+
# Agrega una nueva línea en el fichero
49+
with open("my_file.txt", "a") as my_other_file:
3150
my_other_file.write("\nY Swift")
3251

3352
# os.remove("Intermediate/my_file.txt")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy