Rev 8535 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8535 | superturbo | 1 | # Read/Write file example |
2 | # Copyright (C) 2019-2021 Logaev Maxim (turbocat2001), GPLv3 |
||
3 | |||
8578 | superturbo | 4 | import file |
8535 | superturbo | 5 | |
8578 | superturbo | 6 | fw=file.open('my.txt','w') # Open file for writing |
8535 | superturbo | 7 | fw.write("I love KolibriOS") # Write symbols to my.txt file |
8 | fw.close() # Close file |
||
9 | |||
8578 | superturbo | 10 | fr=file.open('my.txt', 'r') # Open file for reading |
8535 | superturbo | 11 | str=fr.read() # Read symbols from file |
12 | print(str) # Print to console |
||
13 | fr.close() # Close file |