repl.it
@ethanheys/

file handling

Python

No description

fork
loading
Files
  • main.py
  • file.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
import os
file = open("file.txt", "r")
print(file.read())
for line in file:
  print(file.readlines(0))
file.close()

file = open("file.txt","r")
file.write("hp mouse yr5 5")
for line in file:
  print(file.writeline)
file.close()