@HUDSON_REYREY/

Python write to and read from file

Python

No description

fork
loading
Files
  • main.py
  • example.txt
  • tutorial.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
f = open("example.txt","w")

f.write("Writing this to file example.txt.\n")
f.write("And also this.\n")
f.write("And this.")

f.close()

g = open("example.txt","r")

s = g.read()

print(s)

g.close()