The OS module
We can perform many operations on files and get a lot of information about the system using the OS module. Let’s use the REPL to check the functionality offered by the OS module. Let’s import it:
>>> import os
We can retrieve the properties, as follows:
>>> os.uname() (sysname='microbit', nodename='microbit', release='2.0.0', version='Micro:bit v2.0.0+b51a405 on 2021-06-30; MicroPython v1.15-64-g1e2f0d280 on 2021-06-30', machine='Micro:bit with nRF52833')
We can retrieve a list of current files on the Micro:bit’s flash memory:
>>> os.listdir() ['HenryV.txt', 'mylib.py', 'main.py']
We can remove a file, as follows:
>>> os.remove('HenryV.txt') >>> os.listdir() ['mylib.py', 'main.py']
We can see the size, as follows:
>>> os.size('mylib.py') 399
We can...