repl.it
@CBingman/

BasicFileHandling

Python

No description

fork
loading
Files
  • main.py
  • WriteMe.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
print("Python File Writer Program");
write_to_file = open("WriteMe.txt", mode = 'a', encoding='UTF-8');
print("File Info:");
print(write_to_file.name);
print(write_to_file.encoding);
print("Type :Exit when finished typing...");
print("Type :Delete to delete the file");
print("File Ready to Write...");
finished_typing = 0;

while(finished_typing == 0):
  current_line = input();
  if(current_line == ":Exit"):
    break;
  if(current_line == ":Delete"):
    write_to_file.close();
    write_to_file = open("WriteMe.txt", mode = 'w', encoding
     = 'UTF-8');
    print("What would you like to replace the text with...");
    print("Type :Exit to stop");
    continue;
  write_to_file.write(current_line + "\n");
write_to_file.close();

print("\n\n" + write_to_file.name + ":");
read_file = open("WriteMe.txt", mode = 'r', encoding = 'UTF-8');
print(read_file.read());
read_file.close();
Fetching token
?