snipplets.dev/code/MicroPython/read_write_file.py

14 lines
276 B
Python
Raw Permalink Normal View History

2024-05-16 20:38:19 +03:00
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())