snipplets.dev/code/MicroPython/read_write_file.py

14 lines
276 B
Python

import os
print('Listing filesystem...')
print(os.listdir(), '\n')
print('Write data...')
with open('data.txt', 'w') as f:
count = f.write('ololo\n')
print('Write', count, 'bytes')
print('Read data...')
with open('data.txt', 'r') as f:
print('Data:', f.read())